Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/branch.c b/branch.c
index 2b266e6fcb..99a0e7889e 100644
--- a/branch.c
+++ b/branch.c
@@ -2,6 +2,9 @@
#include "cache.h"
#include "config.h"
#include "branch.h"
+#include "environment.h"
+#include "gettext.h"
+#include "hex.h"
#include "refs.h"
#include "refspec.h"
#include "remote.h"
@@ -821,12 +824,16 @@ void remove_branch_state(struct repository *r, int verbose)
void die_if_checked_out(const char *branch, int ignore_current_worktree)
{
struct worktree **worktrees = get_worktrees();
- const struct worktree *wt;
- wt = find_shared_symref(worktrees, "HEAD", branch);
- if (wt && (!ignore_current_worktree || !wt->is_current)) {
- skip_prefix(branch, "refs/heads/", &branch);
- die(_("'%s' is already checked out at '%s'"), branch, wt->path);
+ for (int i = 0; worktrees[i]; i++) {
+ if (worktrees[i]->is_current && ignore_current_worktree)
+ continue;
+
+ if (is_shared_symref(worktrees[i], "HEAD", branch)) {
+ skip_prefix(branch, "refs/heads/", &branch);
+ die(_("'%s' is already checked out at '%s'"),
+ branch, worktrees[i]->path);
+ }
}
free_worktrees(worktrees);