Skip to content

Commit

Permalink
Merge branch 'ks/branch-list-detached-rebase-i'
Browse files Browse the repository at this point in the history
"git branch --list" during an interrupted "rebase -i" now lets
users distinguish the case where a detached HEAD is being rebased
and a normal branch is being rebased.

* ks/branch-list-detached-rebase-i:
  t3200: verify "branch --list" sanity when rebasing from detached HEAD
  branch --list: print useful info whilst interactive rebasing a detached HEAD
  • Loading branch information
gitster committed Apr 25, 2018
2 parents e6986ab + 1f537be commit 4cbaa6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ref-filter.c
Expand Up @@ -1309,10 +1309,14 @@ char *get_head_description(void)
memset(&state, 0, sizeof(state));
wt_status_get_state(&state, 1);
if (state.rebase_in_progress ||
state.rebase_interactive_in_progress)
strbuf_addf(&desc, _("(no branch, rebasing %s)"),
state.branch);
else if (state.bisect_in_progress)
state.rebase_interactive_in_progress) {
if (state.branch)
strbuf_addf(&desc, _("(no branch, rebasing %s)"),
state.branch);
else
strbuf_addf(&desc, _("(no branch, rebasing detached HEAD %s)"),
state.detached_from);
} else if (state.bisect_in_progress)
strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
state.branch);
else if (state.detached_from) {
Expand Down
24 changes: 24 additions & 0 deletions t/t3200-branch.sh
Expand Up @@ -6,6 +6,7 @@
test_description='git branch assorted tests'

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh

test_expect_success 'prepare a trivial repository' '
echo Hello >A &&
Expand Down Expand Up @@ -1246,6 +1247,29 @@ test_expect_success '--merged is incompatible with --no-merged' '
test_must_fail git branch --merged HEAD --no-merged HEAD
'

test_expect_success '--list during rebase' '
test_when_finished "reset_rebase" &&
git checkout master &&
FAKE_LINES="1 edit 2" &&
export FAKE_LINES &&
set_fake_editor &&
git rebase -i HEAD~2 &&
git branch --list >actual &&
test_i18ngrep "rebasing master" actual
'

test_expect_success '--list during rebase from detached HEAD' '
test_when_finished "reset_rebase && git checkout master" &&
git checkout master^0 &&
oid=$(git rev-parse --short HEAD) &&
FAKE_LINES="1 edit 2" &&
export FAKE_LINES &&
set_fake_editor &&
git rebase -i HEAD~2 &&
git branch --list >actual &&
test_i18ngrep "rebasing detached HEAD $oid" actual
'

test_expect_success 'tracking with unexpected .fetch refspec' '
rm -rf a b c d &&
git init a &&
Expand Down

0 comments on commit 4cbaa6b

Please sign in to comment.