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 <sunshine@sunshineco.com> Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Apr 3, 2018 at 20:17 UTC
1f537be3f21ce1289c5c3ed9ebf58f02938ad9f7
1 file changed
+24
t/t3200-branch.sh
+24
@@ -6,6 +6,7 @@
6
test_description='git branch assorted tests'
7
8
. ./test-lib.sh
9
+. "$TEST_DIRECTORY"/lib-rebase.sh
10
11
test_expect_success 'prepare a trivial repository' '
12
echo Hello >A &&
@@ -1246,6 +1247,29 @@ test_expect_success '--merged is incompatible with --no-merged' '
1247
test_must_fail git branch --merged HEAD --no-merged HEAD
1248
'
1249
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
+
1273
test_expect_success 'tracking with unexpected .fetch refspec' '
1274
rm -rf a b c d &&
1275
git init a &&