<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/sequencer.h, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-02-07T00:03:52Z</updated>
<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>
<entry>
<title>create_autostash(): remove unneeded parameter</title>
<updated>2022-01-26T20:08:53Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2022-01-26T13:05:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b7de153bd9332a992baa6f937372f0b1833f61e5'/>
<id>urn:sha1:b7de153bd9332a992baa6f937372f0b1833f61e5</id>
<content type='text'>
The default_reflog parameter of create_autostash() is passed to
reset_head(). However as creating a stash does not involve updating
any refs the parameter is not used by reset_head(). Removing the
parameter from create_autostash() simplifies the callers.

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>Merge branch 'js/retire-preserve-merges'</title>
<updated>2021-10-18T22:47:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-18T22:47:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=223a1bfb5821387981c700654e4edd2443c5a7fc'/>
<id>urn:sha1:223a1bfb5821387981c700654e4edd2443c5a7fc</id>
<content type='text'>
The "--preserve-merges" option of "git rebase" has been removed.

* js/retire-preserve-merges:
  sequencer: restrict scope of a formerly public function
  rebase: remove a no-longer-used function
  rebase: stop mentioning the -p option in comments
  rebase: remove obsolete code comment
  rebase: drop the internal `rebase--interactive` command
  git-svn: drop support for `--preserve-merges`
  rebase: drop support for `--preserve-merges`
  pull: remove support for `--rebase=preserve`
  tests: stop testing `git rebase --preserve-merges`
  remote: warn about unhandled branch.&lt;name&gt;.rebase values
  t5520: do not use `pull.rebase=preserve`
</content>
</entry>
<entry>
<title>Merge branch 'ab/designated-initializers'</title>
<updated>2021-10-11T17:21:48Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-11T17:21:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=404c4a54624c3e0ea9066809344a6269c16de69f'/>
<id>urn:sha1:404c4a54624c3e0ea9066809344a6269c16de69f</id>
<content type='text'>
Code clean-up.

* ab/designated-initializers:
  cbtree.h: define cb_init() in terms of CBTREE_INIT
  *.h: move some *_INIT to designated initializers
  *.h _INIT macros: don't specify fields equal to 0
  *.[ch] *_INIT macros: use { 0 } for a "zero out" idiom
  submodule-config.h: remove unused SUBMODULE_INIT macro
</content>
</entry>
</feed>
