diff options
author | Derrick Stolee <derrickstolee@github.com> | 2022-07-19 20:33:35 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-07-19 21:49:03 +0200 |
commit | aa7f2fd150e7817de6c781dc5911d6c85f334324 (patch) | |
tree | 0de1b907391368987b31a20a9efd7c372eb8a711 /sequencer.h | |
parent | t2407: test branches currently using apply backend (diff) | |
download | git-aa7f2fd150e7817de6c781dc5911d6c85f334324.tar.xz git-aa7f2fd150e7817de6c781dc5911d6c85f334324.zip |
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>
Diffstat (limited to 'sequencer.h')
-rw-r--r-- | sequencer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sequencer.h b/sequencer.h index 698599fe4e..8e38eb5ad7 100644 --- a/sequencer.h +++ b/sequencer.h @@ -233,4 +233,13 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose); int sequencer_get_last_command(struct repository* r, enum replay_action *action); int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); + +/** + * Append the set of ref-OID pairs that are currently stored for the 'git + * rebase --update-refs' feature if such a rebase is currently happening. + * + * Localized to a worktree's git dir. + */ +int sequencer_get_update_refs_state(const char *wt_dir, struct string_list *refs); + #endif /* SEQUENCER_H */ |