diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-03-05 10:43:03 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-05 10:43:03 -0800 |
commit | a0ab37de61c9ac7f57105d6b170947abaf1b642c (patch) | |
tree | 25d416ba467d741ee231dab53392393b795875f4 /builtin/rebase.c | |
parent | 4a2e91db652e197803c6f29e2c2f1c9dfbc16506 (diff) | |
parent | b5cabb4a967fa455378ee7ddfa831a9bf0244753 (diff) | |
download | git-a0ab37de61c9ac7f57105d6b170947abaf1b642c.tar.gz |
Merge branch 'es/do-not-let-rebase-switch-to-protected-branch'
"git rebase BASE BRANCH" rebased/updated the tip of BRANCH and
checked it out, even when the BRANCH is checked out in a different
worktree. This has been corrected.
* es/do-not-let-rebase-switch-to-protected-branch:
rebase: refuse to switch to branch already checked out elsewhere
t3400: make test clean up after itself
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r-- | builtin/rebase.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index ffa467aad5..7bff0c87bc 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -2044,10 +2044,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) /* Is it a local branch? */ strbuf_reset(&buf); strbuf_addf(&buf, "refs/heads/%s", branch_name); - if (!read_ref(buf.buf, &options.orig_head)) + if (!read_ref(buf.buf, &options.orig_head)) { + die_if_checked_out(buf.buf, 1); options.head_name = xstrdup(buf.buf); /* If not is it a valid ref (branch or commit)? */ - else if (!get_oid(branch_name, &options.orig_head)) + } else if (!get_oid(branch_name, &options.orig_head)) options.head_name = NULL; else die(_("fatal: no such branch/commit '%s'"), |