diff options
author | Rubén Justo <rjusto@gmail.com> | 2023-02-25 15:22:02 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-25 22:05:23 +0100 |
commit | faa4d5983bc1739351f49269660285a2628a3d72 (patch) | |
tree | 1855637ae36fae3b0fb6e20e2068c7154b724dde /worktree.c | |
parent | worktree: introduce is_shared_symref() (diff) | |
download | git-faa4d5983bc1739351f49269660285a2628a3d72.tar.xz git-faa4d5983bc1739351f49269660285a2628a3d72.zip |
branch: fix die_if_checked_out() when ignore_current_worktree
In 8d9fdd7 (worktree.c: check whether branch is rebased in another
worktree, 2016-04-22) die_if_checked_out() learned a new option
ignore_current_worktree, to modify the operation from "die() if the
branch is checked out in any worktree" to "die() if the branch is
checked out in any worktree other than the current one".
Unfortunately we implemented it by checking the flag is_current in the
worktree that find_shared_symref() returns.
When the same branch is checked out in several worktrees simultaneously,
find_shared_symref() will return the first matching worktree in the list
composed by get_worktrees(). If one of the worktrees with the checked
out branch is the current worktree, find_shared_symref() may or may not
return it, depending on the order in the list.
Instead of find_shared_symref(), let's do the search using use the
recently introduced API is_shared_symref(), and consider
ignore_current_worktree when necessary.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r-- | worktree.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/worktree.c b/worktree.c index 40cb9874b7..34043d8fe0 100644 --- a/worktree.c +++ b/worktree.c @@ -435,10 +435,9 @@ const struct worktree *find_shared_symref(struct worktree **worktrees, const char *target) { - for (int i = 0; worktrees[i]; i++) { + for (int i = 0; worktrees[i]; i++) if (is_shared_symref(worktrees[i], symref, target)) return worktrees[i]; - } return NULL; } |