<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/update-ref.c, branch v2.30.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.30.4</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.30.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-11-16T21:44:01Z</updated>
<entry>
<title>update-ref: disallow "start" for ongoing transactions</title>
<updated>2020-11-16T21:44:01Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-11-13T08:12:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8c4417f1cf3c78955a7ea942cc0c8a97e7c77e77'/>
<id>urn:sha1:8c4417f1cf3c78955a7ea942cc0c8a97e7c77e77</id>
<content type='text'>
It is currently possible to write multiple "start" commands into
git-update-ref(1) for a single session, but none of them except for the
first one actually have any effect.

Using such nested "start"s may eventually have a sensible effect. One
may imagine that it restarts the current transaction, effectively
emptying it and creating a new one. It may also allow for creation of
nested transactions. But currently, none of these are implemented.

Silently ignoring this misuse is making it hard to iterate in the future
if "start" is ever going to have meaningful semantics in such a context.
This commit thus makes sure to error out in case we see such use.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Reviewed-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: allow creation of multiple transactions</title>
<updated>2020-11-16T21:44:01Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-11-13T08:12:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=262a4d28feb26aff89705b3254cdfc015eaa3ef9'/>
<id>urn:sha1:262a4d28feb26aff89705b3254cdfc015eaa3ef9</id>
<content type='text'>
While git-update-ref has recently grown commands which allow interactive
control of transactions in e48cf33b61 (update-ref: implement interactive
transaction handling, 2020-04-02), it is not yet possible to create
multiple transactions in a single session. To do so, one currently still
needs to invoke the executable multiple times.

This commit addresses this shortcoming by allowing the "start" command
to create a new transaction if the current transaction has already been
either committed or aborted.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Reviewed-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>strvec: rename files from argv-array to strvec</title>
<updated>2020-07-28T22:02:17Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-07-28T20:23:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dbbcd44fb47347a3fdbee88ea21805b7f4ac0b98'/>
<id>urn:sha1:dbbcd44fb47347a3fdbee88ea21805b7f4ac0b98</id>
<content type='text'>
This requires updating #include lines across the code-base, but that's
all fairly mechanical, and was done with:

  git ls-files '*.c' '*.h' |
  xargs perl -i -pe 's/argv-array.h/strvec.h/'

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: implement interactive transaction handling</title>
<updated>2020-04-02T18:09:49Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:10:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e48cf33b61b8fecf1558fb32fcf5ee2987e82890'/>
<id>urn:sha1:e48cf33b61b8fecf1558fb32fcf5ee2987e82890</id>
<content type='text'>
The git-update-ref(1) command can only handle queueing transactions
right now via its "--stdin" parameter, but there is no way for users to
handle the transaction itself in a more explicit way. E.g. in a
replicated scenario, one may imagine a coordinator that spawns
git-update-ref(1) for multiple repositories and only if all agree that
an update is possible will the coordinator send a commit. Such a
transactional session could look like

    &gt; start
    &lt; start: ok
    &gt; update refs/heads/master $OLD $NEW
    &gt; prepare
    &lt; prepare: ok
    # All nodes have returned "ok"
    &gt; commit
    &lt; commit: ok

or

    &gt; start
    &lt; start: ok
    &gt; create refs/heads/master $OLD $NEW
    &gt; prepare
    &lt; fatal: cannot lock ref 'refs/heads/master': reference already exists
    # On all other nodes:
    &gt; abort
    &lt; abort: ok

In order to allow for such transactional sessions, this commit
introduces four new commands for git-update-ref(1), which matches those
we have internally already with the exception of "start":

    - start: start a new transaction

    - prepare: prepare the transaction, that is try to lock all
               references and verify their current value matches the
               expected one

    - commit: explicitly commit a session, that is update references to
              match their new expected state

    - abort: abort a session and roll back all changes

By design, git-update-ref(1) will commit as soon as standard input is
being closed. While fine in a non-transactional world, it is definitely
unexpected in a transactional world. Because of this, as soon as any of
the new transactional commands is used, the default will change to
aborting without an explicit "commit". To avoid a race between queueing
updates and the first "prepare" that starts a transaction, the "start"
command has been added to start an explicit transaction.

Add some tests to exercise this new functionality.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: read commands in a line-wise fashion</title>
<updated>2020-04-02T18:09:49Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:09:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=94fd491a54b955990146f63e7283e9813dc85fef'/>
<id>urn:sha1:94fd491a54b955990146f63e7283e9813dc85fef</id>
<content type='text'>
The git-update-ref(1) supports a `--stdin` mode that allows it to read
all reference updates from standard input. This is mainly used to allow
for atomic reference updates that are all or nothing, so that either all
references will get updated or none.

Currently, git-update-ref(1) reads all commands as a single block of up
to 1000 characters and only starts processing after stdin gets closed.
This is less flexible than one might wish for, as it doesn't really
allow for longer-lived transactions and doesn't allow any verification
without committing everything. E.g. one may imagine the following
exchange:

    &gt; start
    &lt; start: ok
    &gt; update refs/heads/master $NEWOID1 $OLDOID1
    &gt; update refs/heads/branch $NEWOID2 $OLDOID2
    &gt; prepare
    &lt; prepare: ok
    &gt; commit
    &lt; commit: ok

When reading all input as a whole block, the above interactive protocol
is obviously impossible to achieve. But by converting the command to
read commands linewise, we can make it more interactive than before.

Obviously, the linewise interface is only a first step in making
git-update-ref(1) work in a more transaction-oriented way. Missing is
most importantly support for transactional commands that manage the
current transaction.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: move transaction handling into `update_refs_stdin()`</title>
<updated>2020-04-02T18:09:48Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:09:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de0e0d650a1c2afc81a4c5e8d37d266ffa2b8ccf'/>
<id>urn:sha1:de0e0d650a1c2afc81a4c5e8d37d266ffa2b8ccf</id>
<content type='text'>
While the actual logic to update the transaction is handled in
`update_refs_stdin()`, the transaction itself is started and committed
in `cmd_update_ref()` itself. This makes it hard to handle transaction
abortion and commits as part of `update_refs_stdin()` itself, which is
required in order to introduce transaction handling features to `git
update-refs --stdin`.

Refactor the code to move all transaction handling into
`update_refs_stdin()` to prepare for transaction handling features.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: pass end pointer instead of strbuf</title>
<updated>2020-04-02T18:09:48Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:09:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=804dba54f5abdb35b5d15eed63625581c82697fb'/>
<id>urn:sha1:804dba54f5abdb35b5d15eed63625581c82697fb</id>
<content type='text'>
We currently pass both an `strbuf` containing the current command line
as well as the `next` pointer pointing to the first argument to
commands. This is both confusing and makes code more intertwined.
Convert this to use a simple pointer as well as a pointer pointing to
the end of the input as a preparatory step to line-wise reading of
stdin.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: drop unused argument for `parse_refname`</title>
<updated>2020-04-02T18:09:48Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:09:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ae6c5a7129a55e69d39cfb70c78bb5b92bbccb7'/>
<id>urn:sha1:5ae6c5a7129a55e69d39cfb70c78bb5b92bbccb7</id>
<content type='text'>
The `parse_refname` function accepts a `struct strbuf *input` argument
that isn't used at all. As we're about to convert commands to not use a
strbuf anymore but instead an end pointer, let's drop this argument now
to make the converting commit easier to review.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: organize commands in an array</title>
<updated>2020-04-02T18:09:48Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-04-02T07:09:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a65b8ac291d919c8f0c89f7397e03662020344ab'/>
<id>urn:sha1:a65b8ac291d919c8f0c89f7397e03662020344ab</id>
<content type='text'>
We currently manually wire up all commands known to `git-update-ref
--stdin`, making it harder than necessary to preprocess arguments after
the command is determined. To make this more extensible, let's refactor
the code to use an array of known commands instead. While this doesn't
add a lot of value now, it is a preparatory step to implement line-wise
reading of commands.

As we're going to introduce commands without trailing spaces, this
commit also moves whitespace parsing into the respective commands.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>update-ref: allow --no-deref with --stdin</title>
<updated>2018-09-12T22:17:17Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2018-09-05T17:25:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d345e9fbe75c8bec6469253f0ee7e34228f41917'/>
<id>urn:sha1:d345e9fbe75c8bec6469253f0ee7e34228f41917</id>
<content type='text'>
If passed both --no-deref and --stdin, update-ref would error out with a
general usage message that did not at all suggest these options were
incompatible.  The manpage for update-ref did suggest through its
synopsis line that --no-deref and --stdin were incompatible, but it sadly
also incorrectly suggested that -d and --no-deref were incompatible.  So
the help around the --no-deref option is buggy in a few ways.

The --stdin option did provide a different mechanism for avoiding
dereferencing symbolic-refs: adding a line reading
  option no-deref
before every other directive in the input.  (Technically, if the user
wants to do the extra work of first determining which refs they want to
update or delete are symbolic, then they only need to put the extra
"option no-deref" lines before the updates of those refs.  But in some
cases, that's more work than just adding the "option no-deref" before
every other directive.)

It's easier to allow the user to just pass --no-deref along with --stdin
in order to tell update-ref that the user doesn't want any symbolic ref
to be dereferenced.  It also makes the update-ref documentation simpler.
Implement that, and update the documentation to match.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
