]> git.ipfire.org Git - thirdparty/git.git/commit - sequencer.c
branch: consider refs under 'update-refs'
authorDerrick Stolee <derrickstolee@github.com>
Tue, 19 Jul 2022 18:33:35 +0000 (18:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jul 2022 19:49:03 +0000 (12:49 -0700)
commitaa7f2fd150e7817de6c781dc5911d6c85f334324
tree0de1b907391368987b31a20a9efd7c372eb8a711
parent18ea59582778bd0b80fc643bc4e2981275d2300d
branch: consider refs under 'update-refs'

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 <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
sequencer.c
sequencer.h
t/t2407-worktree-heads.sh