Skip to content

Commit 1f537be

Browse files
sunshinecogitster
authored andcommitted
t3200: verify "branch --list" sanity when rebasing from detached HEAD
"git branch --list" shows an in-progress rebase as: * (no branch, rebasing <branch>) master ... However, if the rebase is started from a detached HEAD, then there is no <branch>, and it would attempt to print a NULL pointer. The previous commit fixed this problem, so add a test to verify that the output is sane in this situation. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a236f90 commit 1f537be

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

t/t3200-branch.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
test_description='git branch assorted tests'
77

88
. ./test-lib.sh
9+
. "$TEST_DIRECTORY"/lib-rebase.sh
910

1011
test_expect_success 'prepare a trivial repository' '
1112
echo Hello >A &&
@@ -1246,6 +1247,29 @@ test_expect_success '--merged is incompatible with --no-merged' '
12461247
test_must_fail git branch --merged HEAD --no-merged HEAD
12471248
'
12481249

1250+
test_expect_success '--list during rebase' '
1251+
test_when_finished "reset_rebase" &&
1252+
git checkout master &&
1253+
FAKE_LINES="1 edit 2" &&
1254+
export FAKE_LINES &&
1255+
set_fake_editor &&
1256+
git rebase -i HEAD~2 &&
1257+
git branch --list >actual &&
1258+
test_i18ngrep "rebasing master" actual
1259+
'
1260+
1261+
test_expect_success '--list during rebase from detached HEAD' '
1262+
test_when_finished "reset_rebase && git checkout master" &&
1263+
git checkout master^0 &&
1264+
oid=$(git rev-parse --short HEAD) &&
1265+
FAKE_LINES="1 edit 2" &&
1266+
export FAKE_LINES &&
1267+
set_fake_editor &&
1268+
git rebase -i HEAD~2 &&
1269+
git branch --list >actual &&
1270+
test_i18ngrep "rebasing detached HEAD $oid" actual
1271+
'
1272+
12491273
test_expect_success 'tracking with unexpected .fetch refspec' '
12501274
rm -rf a b c d &&
12511275
git init a &&

0 commit comments

Comments
 (0)