<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/sequencer.h, branch v2.43.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.43.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.43.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-04-10T16:53:19Z</updated>
<entry>
<title>rebase -m: cleanup --strategy-option handling</title>
<updated>2023-04-10T16:53:19Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2023-04-10T09:08:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4a8bc9860aa09942dd0e6540d53102219a7e920d'/>
<id>urn:sha1:4a8bc9860aa09942dd0e6540d53102219a7e920d</id>
<content type='text'>
When handling "--strategy-option" rebase collects the commands into a
struct string_list, then concatenates them into a string, prepending "--"
to each one before splitting the string and removing the "--" prefix.
This is an artifact of the scripted rebase and the need to support
"rebase --preserve-merges". Now that "--preserve-merges" no-longer
exists we can cleanup the way the argument is handled.

The tests for a bad strategy option are adjusted now that
parse_strategy_opts() is no-longer called when starting a rebase. The
fact that it only errors out when running "git rebase --continue" is a
mixed blessing but the next commit will fix the root cause of the
parsing problem so lets not worry about that here.

Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: use struct strvec to store merge strategy options</title>
<updated>2023-04-10T16:53:19Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2023-04-10T09:08:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fb60b9f37f87241a886e183f0ec6261debb9c1c5'/>
<id>urn:sha1:fb60b9f37f87241a886e183f0ec6261debb9c1c5</id>
<content type='text'>
The sequencer stores the merge strategy options in an array of strings
which allocated with ALLOC_GROW(). Using "struct strvec" avoids manually
managing the memory of that array and simplifies the code.

Aside from memory allocation the changes to the sequencer are largely
mechanical, changing xopts_nr to xopts.nr and xopts[i] to xopts.v[i]. A
new option parsing macro OPT_STRVEC() is also added to collect the
strategy options.  Hopefully this can be used to simplify the code in
builtin/merge.c in the future.

Note that there is a change of behavior to "git cherry-pick" and "git
revert" as passing “--no-strategy-option” will now clear any previous
strategy options whereas before this change it did nothing.

Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>treewide: remove unnecessary cache.h includes</title>
<updated>2023-02-24T01:25:28Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-02-24T00:09:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ba3d1c73daa02152acf4729d45ca7fe4d71d5747'/>
<id>urn:sha1:ba3d1c73daa02152acf4729d45ca7fe4d71d5747</id>
<content type='text'>
We had several header files include cache.h unnecessarily.  Remove
those.  These have all been verified via both ensuring that
    gcc -E $HEADER | grep '"cache.h"'
found no hits and that
    cat &gt;temp.c &lt;&lt;EOF &amp;&amp;
    #include "git-compat-util.h"
    #include "$HEADER"
    int main() {}
    EOF
    gcc -c temp.c
successfully compiles without warnings.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer API users: fix get_replay_opts() leaks</title>
<updated>2023-02-07T00:03:52Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2023-02-06T19:08:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9ff2f0606915cf76fc4865bddf639fd5fd2cba29'/>
<id>urn:sha1:9ff2f0606915cf76fc4865bddf639fd5fd2cba29</id>
<content type='text'>
Make the replay_opts_release() function added in the preceding commit
non-static, and use it for freeing the "struct replay_opts"
constructed for "rebase" and "revert".

To safely call our new replay_opts_release() we'll need to stop
calling it in sequencer_remove_state(), and instead call it where we
allocate the "struct replay_opts" itself.

This is because in e.g. do_interactive_rebase() we construct a "struct
replay_opts" with "get_replay_opts()", and then call
"complete_action()". If we get far enough in that function without
encountering errors we'll call "pick_commits()" which (indirectly)
calls sequencer_remove_state() at the end.

But if we encounter errors anywhere along the way we'd punt out early,
and not free() the memory we allocated. Remembering whether we
previously called sequencer_remove_state() would be a hassle.

Using a FREE_AND_NULL() pattern would also work, as it would be safe
to call replay_opts_release() repeatedly. But let's fix this properly
instead, by having the owner of the data free() it.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: stop exporting GIT_REFLOG_ACTION</title>
<updated>2022-11-09T23:15:43Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2022-11-09T14:21:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d188a60d7228f051bb4004924d20d961ada636f3'/>
<id>urn:sha1:d188a60d7228f051bb4004924d20d961ada636f3</id>
<content type='text'>
Each time it picks a commit the sequencer copies the GIT_REFLOG_ACITON
environment variable so it can temporarily change it and then restore
the previous value. This results in code that is hard to follow and also
leaks memory because (i) we fail to free the copy when we've finished
with it and (ii) each call to setenv() leaks the previous value. Instead
pass the reflog action around in a variable and use it to set
GIT_REFLOG_ACTION in the child environment when running "git commit".

Within the sequencer GIT_REFLOG_ACTION is no longer set and is only read
by sequencer_reflog_action(). It is still set by rebase before calling
the sequencer, that will be addressed in the next commit. cherry-pick
and revert are unaffected as they do not set GIT_REFLOG_ACTION before
calling the sequencer.

Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Reviewed-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
</content>
</entry>
<entry>
<title>sequencer: rewrite update-refs as user edits todo list</title>
<updated>2022-07-19T19:49:04Z</updated>
<author>
<name>Derrick Stolee</name>
<email>derrickstolee@github.com</email>
</author>
<published>2022-07-19T18:33:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b3b1a21d1a5df87e81fa8b53c6c3cf9760ca12d4'/>
<id>urn:sha1:b3b1a21d1a5df87e81fa8b53c6c3cf9760ca12d4</id>
<content type='text'>
An interactive rebase provides opportunities for the user to edit the
todo list. The --update-refs option initializes the list with some
'update-ref &lt;ref&gt;' steps, but the user could add these manually.
Further, the user could add or remove these steps during pauses in the
interactive rebase.

Add a new method, todo_list_filter_update_refs(), that scans a todo_list
and compares it to the stored update-refs file. There are two actions
that can happen at this point:

1. If a '&lt;ref&gt;/&lt;before&gt;/&lt;after&gt;' triple in the update-refs file does not
   have a matching 'update-ref &lt;ref&gt;' command in the todo-list _and_ the
   &lt;after&gt; value is the null OID, then remove that triple. Here, the
   user removed the 'update-ref &lt;ref&gt;' command before it was executed,
   since if it was executed then the &lt;after&gt; value would store the
   commit at that position.

2. If a 'update-ref &lt;ref&gt;' command in the todo-list does not have a
   matching '&lt;ref&gt;/&lt;before&gt;/&lt;after&gt;' triple in the update-refs file,
   then insert a new one. Store the &lt;before&gt; value to be the current
   OID pointed at by &lt;ref&gt;. This is handled inside of the
   init_update_ref_record() helper method.

We can test that this works by rewriting the todo-list several times in
the course of a rebase. Check that each ref is locked or unlocked for
updates after each todo-list update. We can also verify that the ref
update fails if a concurrent process updates one of the refs after the
rebase process records the "locked" ref location.

To help these tests, add a new 'set_replace_editor' helper that will
replace the todo-list with an exact file.

Reported-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Signed-off-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>rebase: add --update-refs option</title>
<updated>2022-07-19T19:49:04Z</updated>
<author>
<name>Derrick Stolee</name>
<email>derrickstolee@github.com</email>
</author>
<published>2022-07-19T18:33:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=900b50c242dfa6b47033cbb495d2fd9d06752ff1'/>
<id>urn:sha1:900b50c242dfa6b47033cbb495d2fd9d06752ff1</id>
<content type='text'>
When working on a large feature, it can be helpful to break that feature
into multiple smaller parts that become reviewed in sequence. During
development or during review, a change to one part of the feature could
affect multiple of these parts. An interactive rebase can help adjust
the multi-part "story" of the branch.

However, if there are branches tracking the different parts of the
feature, then rebasing the entire list of commits can create commits not
reachable from those "sub branches". It can take a manual step to update
those branches.

Add a new --update-refs option to 'git rebase -i' that adds 'update-ref
&lt;ref&gt;' steps to the todo file whenever a commit that is being rebased is
decorated with that &lt;ref&gt;. At the very end, the rebase process updates
all of the listed refs to the values stored during the rebase operation.

Be sure to iterate after any squashing or fixups are placed. Update the
branch only after those squashes and fixups are complete. This allows a
--fixup commit at the tip of the feature to apply correctly to the sub
branch, even if it is fixing up the most-recent commit in that part.

This change update the documentation and builtin to accept the
--update-refs option as well as updating the todo file with the
'update-ref' commands. Tests are added to ensure that these todo
commands are added in the correct locations.

This change does _not_ include the actual behavior of tracking the
updated refs and writing the new ref values at the end of the rebase
process. That is deferred to a later change.

Signed-off-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: add update-ref command</title>
<updated>2022-07-19T19:49:03Z</updated>
<author>
<name>Derrick Stolee</name>
<email>derrickstolee@github.com</email>
</author>
<published>2022-07-19T18:33:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a97d79163e16e2d3777ab4d86c8f006f260c2836'/>
<id>urn:sha1:a97d79163e16e2d3777ab4d86c8f006f260c2836</id>
<content type='text'>
Add the boilerplate for an "update-ref" command in the sequencer. This
connects to the current no-op do_update_ref() which will be filled in
after more connections are created.

The syntax in the todo list will be "update-ref &lt;ref-name&gt;" to signal
that we should store the current commit as the value for updating
&lt;ref-name&gt; at the end of the rebase.

Signed-off-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>branch: consider refs under 'update-refs'</title>
<updated>2022-07-19T19:49:03Z</updated>
<author>
<name>Derrick Stolee</name>
<email>derrickstolee@github.com</email>
</author>
<published>2022-07-19T18:33:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=aa7f2fd150e7817de6c781dc5911d6c85f334324'/>
<id>urn:sha1:aa7f2fd150e7817de6c781dc5911d6c85f334324</id>
<content type='text'>
The branch_checked_out() helper helps commands like 'git branch' and
'git fetch' from overwriting refs that are currently checked out in
other worktrees.

A future update to 'git rebase' will introduce a new '--update-refs'
option which will update the local refs that point to commits that are
being rebased. To avoid collisions as the rebase completes, we want to
make the future data store for these refs to be considered by
branch_checked_out().

The data store is a plaintext file inside the 'rebase-merge' directory
for that worktree. The file lists refnames followed by two OIDs, each on
separate lines. The OIDs will be used to store the original values of
the refs and the to-be-written values as the rebase progresses, but can
be ignored at the moment.

Create a new sequencer_get_update_refs_state() method that parses this
file and populates a struct string_list with the ref-OID pairs. We can
then use this list to add to the current_checked_out_branches strmap
used by branch_checked_out().

To properly navigate to the rebase directory for a given worktree,
extract the static strbuf_worktree_gitdir() method to a public API
method.

We can test that this works without having Git write this file by
artificially creating one in our test script, at least until 'git rebase
--update-refs' is implemented and we can use it directly.

Signed-off-by: Derrick Stolee &lt;derrickstolee@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>revert: optionally refer to commit in the "reference" format</title>
<updated>2022-05-27T06:05:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-05-27T06:01:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=43966ab3156a082067bf9930351e96e9488da735'/>
<id>urn:sha1:43966ab3156a082067bf9930351e96e9488da735</id>
<content type='text'>
A typical "git revert" commit uses the full title of the original
commit in its title, and starts its body of the message with:

    This reverts commit 8fa7f667cf61386257c00d6e954855cc3215ae91.

This does not encourage the best practice of describing not just
"what" (i.e. "Revert X" on the title says what we did) but "why"
(i.e. and it does not say why X was undesirable).

We can instead phrase this first line of the body to be more like

    This reverts commit 8fa7f667 (do this and that, 2022-04-25)

so that the title does not have to be

    Revert "do this and that"

We can instead use the title to describe "why" we are reverting the
original commit.

Introduce the "--reference" option to "git revert", and also the
revert.reference configuration variable, which defaults to false, to
tweak the title and the first line of the draft commit message for
when creating a "revert" commit.

When this option is in use, the first line of the pre-filled editor
buffer becomes a comment line that tells the user to say _why_.  If
the user exits the editor without touching this line by mistake,
what we prepare to become the first line of the body, i.e. "This
reverts commit 8fa7f667 (do this and that, 2022-04-25)", ends up to
be the title of the resulting commit.  This behaviour is designed to
help such a user to identify such a revert in "git log --oneline"
easily so that it can be further reworded with "git rebase -i" later.

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