ref_array_clear(&array);
}
+static void reject_rebase_or_bisect_branch(const char *target)
+{
+ struct worktree **worktrees = get_worktrees();
+ int i;
+
+ for (i = 0; worktrees[i]; i++) {
+ struct worktree *wt = worktrees[i];
+
+ if (!wt->is_detached)
+ continue;
+
+ if (is_worktree_being_rebased(wt, target))
+ die(_("Branch %s is being rebased at %s"),
+ target, wt->path);
+
+ if (is_worktree_being_bisected(wt, target))
+ die(_("Branch %s is being bisected at %s"),
+ target, wt->path);
+ }
+
+ free_worktrees(worktrees);
+}
+
static void rename_branch(const char *oldname, const char *newname, int force)
{
struct strbuf oldref = STRBUF_INIT, newref = STRBUF_INIT, logmsg = STRBUF_INIT;
validate_new_branchname(newname, &newref, force, clobber_head_ok);
+ reject_rebase_or_bisect_branch(oldref.buf);
+
strbuf_addf(&logmsg, "Branch: renamed %s to %s",
oldref.buf, newref.buf);
)
'
+test_expect_success 'rename a branch under rebase not allowed' '
+ test_must_fail git branch -M under-rebase rebase-with-new-name
+'
+
test_expect_success 'check out from current worktree branch ok' '
(
cd under-rebase &&
)
'
+test_expect_success 'rename a branch under bisect not allowed' '
+ test_must_fail git branch -M under-bisect bisect-with-new-name
+'
+
test_done
return git_common_path("worktrees/%s", wt->id);
}
-static int is_worktree_being_rebased(const struct worktree *wt,
- const char *target)
+int is_worktree_being_rebased(const struct worktree *wt,
+ const char *target)
{
struct wt_status_state state;
int found_rebase;
return found_rebase;
}
-static int is_worktree_being_bisected(const struct worktree *wt,
- const char *target)
+int is_worktree_being_bisected(const struct worktree *wt,
+ const char *target)
{
struct wt_status_state state;
int found_rebase;
extern const struct worktree *find_shared_symref(const char *symref,
const char *target);
+int is_worktree_being_rebased(const struct worktree *wt, const char *target);
+int is_worktree_being_bisected(const struct worktree *wt, const char *target);
+
/*
* Similar to git_path() but can produce paths for a specified
* worktree instead of current one