t3404: do not depend on any specific default branch name

Now that we can override the default branch name in the tests via `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME`, we should avoid expecting a particular hard-coded name. So let's rename the initial branch immediately to `primary` and work with that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 24, 2020 at 10:15 UTC 9c8509a4e36b4795237b840f2c7972a3ad401425
1 file changed +45 -44
t/t3404-rebase-interactive.sh
+45 -44
@@ -12,7 +12,7 @@ Initial setup:
12
13 one - two - three - four (conflict-branch)
14 /
15 - A - B - C - D - E (master)
15 + A - B - C - D - E (primary)
16 | \
17 | F - G - H (branch1)
18 | \
@@ -30,6 +30,7 @@ Initial setup:
30 . "$TEST_DIRECTORY"/lib-rebase.sh
31
32 test_expect_success 'setup' '
33 + git switch -C primary &&
34 test_commit A file1 &&
35 test_commit B file1 &&
36 test_commit C file2 &&
@@ -65,7 +66,7 @@ SHELL=
66 export SHELL
67
68 test_expect_success 'rebase --keep-empty' '
68 - git checkout -b emptybranch master &&
69 + git checkout -b emptybranch primary &&
70 git commit --allow-empty -m "empty" &&
71 git rebase --keep-empty -i HEAD~2 &&
72 git log --oneline >actual &&
@@ -86,7 +87,7 @@ test_expect_success 'rebase -i with empty todo list' '
87 '
88
89 test_expect_success 'rebase -i with the exec command' '
89 - git checkout master &&
90 + git checkout primary &&
91 (
92 set_fake_editor &&
93 FAKE_LINES="1 exec_>touch-one
@@ -103,12 +104,12 @@ test_expect_success 'rebase -i with the exec command' '
104 test_path_is_file touch-three &&
105 test_path_is_file "touch-file name with spaces" &&
106 test_path_is_file touch-after-semicolon &&
106 - test_cmp_rev master HEAD &&
107 + test_cmp_rev primary HEAD &&
108 rm -f touch-*
109 '
110
111 test_expect_success 'rebase -i with the exec command runs from tree root' '
111 - git checkout master &&
112 + git checkout primary &&
113 mkdir subdir && (cd subdir &&
114 set_fake_editor &&
115 FAKE_LINES="1 exec_>touch-subdir" \
@@ -121,7 +122,7 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
122 test_expect_success 'rebase -i with exec allows git commands in subdirs' '
123 test_when_finished "rm -rf subdir" &&
124 test_when_finished "git rebase --abort ||:" &&
124 - git checkout master &&
125 + git checkout primary &&
126 mkdir subdir && (cd subdir &&
127 set_fake_editor &&
128 FAKE_LINES="1 x_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
@@ -139,13 +140,13 @@ test_expect_success 'rebase -i sets work tree properly' '
140 '
141
142 test_expect_success 'rebase -i with the exec command checks tree cleanness' '
142 - git checkout master &&
143 + git checkout primary &&
144 (
145 set_fake_editor &&
146 test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" \
147 git rebase -i HEAD^
148 ) &&
148 - test_cmp_rev master^ HEAD &&
149 + test_cmp_rev primary^ HEAD &&
150 git reset --hard &&
151 git rebase --continue
152 '
@@ -168,7 +169,7 @@ test_expect_success 'rebase -x with newline in command fails' '
169 '
170
171 test_expect_success 'rebase -i with exec of inexistent command' '
171 - git checkout master &&
172 + git checkout primary &&
173 test_when_finished "git rebase --abort" &&
174 (
175 set_fake_editor &&
@@ -259,8 +260,8 @@ test_expect_success 'stop on conflicting pick' '
260 >>>>>>> $commit (G)
261 EOF
262 git tag new-branch1 &&
262 - test_must_fail git rebase -i master &&
263 - test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" &&
263 + test_must_fail git rebase -i primary &&
264 + test "$(git rev-parse HEAD~3)" = "$(git rev-parse primary)" &&
265 test_cmp expect .git/rebase-merge/patch &&
266 test_cmp expect2 file1 &&
267 test "$(git diff --name-status |
@@ -287,7 +288,7 @@ test_expect_success 'abort' '
288 test_expect_success 'abort with error when new base cannot be checked out' '
289 git rm --cached file1 &&
290 git commit -m "remove file in base" &&
290 - test_must_fail git rebase -i master > output 2>&1 &&
291 + test_must_fail git rebase -i primary > output 2>&1 &&
292 test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
293 output &&
294 test_i18ngrep "file1" output &&
@@ -301,7 +302,7 @@ test_expect_success 'retain authorship' '
302 test_tick &&
303 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
304 git tag twerp &&
304 - git rebase -i --onto master HEAD^ &&
305 + git rebase -i --onto primary HEAD^ &&
306 git show HEAD | grep "^Author: Twerp Snog"
307 '
308
@@ -336,10 +337,10 @@ test_expect_success 'squash' '
337 (
338 set_fake_editor &&
339 FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \
339 - git rebase -i --onto master HEAD~2
340 + git rebase -i --onto primary HEAD~2
341 ) &&
342 test B = $(cat file7) &&
342 - test_cmp_rev HEAD^ master
343 + test_cmp_rev HEAD^ primary
344 '
345
346 test_expect_success 'retain authorship when squashing' '
@@ -366,12 +367,12 @@ test_expect_failure REBASE_P 'exchange two commits with -p' '
367 '
368
369 test_expect_success REBASE_P 'preserve merges with -p' '
369 - git checkout -b to-be-preserved master^ &&
370 + git checkout -b to-be-preserved primary^ &&
371 : > unrelated-file &&
372 git add unrelated-file &&
373 test_tick &&
374 git commit -m "unrelated" &&
374 - git checkout -b another-branch master &&
375 + git checkout -b another-branch primary &&
376 echo B > file1 &&
377 test_tick &&
378 git commit -m J file1 &&
@@ -394,7 +395,7 @@ test_expect_success REBASE_P 'preserve merges with -p' '
395 git commit -m M file1 &&
396 git checkout -b to-be-rebased &&
397 test_tick &&
397 - git rebase -i -p --onto branch1 master &&
398 + git rebase -i -p --onto branch1 primary &&
399 git update-index --refresh &&
400 git diff-files --quiet &&
401 git diff-index --quiet --cached HEAD -- &&
@@ -437,7 +438,7 @@ test_expect_success '--continue tries to commit' '
438 '
439
440 test_expect_success 'verbose flag is heeded, even after --continue' '
440 - git reset --hard master@{1} &&
441 + git reset --hard primary@{1} &&
442 test_tick &&
443 test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
444 echo resolved > file1 &&
@@ -802,7 +803,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
803 '
804
805 test_expect_success 'avoid unnecessary reset' '
805 - git checkout master &&
806 + git checkout primary &&
807 git reset --hard &&
808 test-tool chmtime =123456789 file3 &&
809 git update-index --refresh &&
@@ -814,14 +815,14 @@ test_expect_success 'avoid unnecessary reset' '
815 '
816
817 test_expect_success 'reword' '
817 - git checkout -b reword-branch master &&
818 + git checkout -b reword-branch primary &&
819 (
820 set_fake_editor &&
821 FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \
822 git rebase -i A &&
823 git show HEAD | grep "E changed" &&
823 - test $(git rev-parse master) != $(git rev-parse HEAD) &&
824 - test_cmp_rev master^ HEAD^ &&
824 + test $(git rev-parse primary) != $(git rev-parse HEAD) &&
825 + test_cmp_rev primary^ HEAD^ &&
826 FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
827 git rebase -i A &&
828 git show HEAD^ | grep "D changed" &&
@@ -918,7 +919,7 @@ test_expect_success 'rebase-i history with funny messages' '
919 '
920
921 test_expect_success 'prepare for rebase -i --exec' '
921 - git checkout master &&
922 + git checkout primary &&
923 git checkout -b execute &&
924 test_commit one_exec main.txt one_exec &&
925 test_commit two_exec main.txt two_exec &&
@@ -1027,7 +1028,7 @@ test_expect_success 'rebase -i --exec without <CMD>' '
1028 git reset --hard execute &&
1029 test_must_fail git rebase -i --exec 2>actual &&
1030 test_i18ngrep "requires a value" actual &&
1030 - git checkout master
1031 + git checkout primary
1032 '
1033
1034 test_expect_success 'rebase -i --root re-order and drop commits' '
@@ -1079,7 +1080,7 @@ test_expect_success 'rebase -i --root fixup root commit' '
1080
1081 test_expect_success 'rebase -i --root reword original root commit' '
1082 test_when_finished "test_might_fail git rebase --abort" &&
1082 - git checkout -b reword-original-root-branch master &&
1083 + git checkout -b reword-original-root-branch primary &&
1084 (
1085 set_fake_editor &&
1086 FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
@@ -1091,7 +1092,7 @@ test_expect_success 'rebase -i --root reword original root commit' '
1092
1093 test_expect_success 'rebase -i --root reword new root commit' '
1094 test_when_finished "test_might_fail git rebase --abort" &&
1094 - git checkout -b reword-now-root-branch master &&
1095 + git checkout -b reword-now-root-branch primary &&
1096 (
1097 set_fake_editor &&
1098 FAKE_LINES="reword 3 1" FAKE_COMMIT_MESSAGE="C changed" \
@@ -1251,7 +1252,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
1252 '
1253
1254 test_expect_success 'short commit ID setup' '
1254 - test_when_finished "git checkout master" &&
1255 + test_when_finished "git checkout primary" &&
1256 git checkout --orphan collide &&
1257 git rm -rf . &&
1258 (
@@ -1292,7 +1293,7 @@ test_expect_success 'short commit ID collide' '
1293 t3404_collider sha1:ac4f2ee
1294 t3404_collider sha256:16697
1295 EOF
1295 - test_when_finished "reset_rebase && git checkout master" &&
1296 + test_when_finished "reset_rebase && git checkout primary" &&
1297 git checkout collide &&
1298 colliding_id=$(test_oid t3404_collision) &&
1299 hexsz=$(test_oid hexsz) &&
@@ -1416,11 +1417,11 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
1417
1418 rebase_setup_and_clean () {
1419 test_when_finished "
1419 - git checkout master &&
1420 + git checkout primary &&
1421 test_might_fail git branch -D $1 &&
1422 test_might_fail git rebase --abort
1423 " &&
1423 - git checkout -b $1 ${2:-master}
1424 + git checkout -b $1 ${2:-primary}
1425 }
1426
1427 test_expect_success 'drop' '
@@ -1451,7 +1452,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
1452 cat >expect <<-EOF &&
1453 Warning: some commits may have been dropped accidentally.
1454 Dropped commits (newer to older):
1454 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1455 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1456 To avoid this message, use "drop" to explicitly remove a commit.
1457 EOF
1458 test_config rebase.missingCommitsCheck warn &&
@@ -1469,8 +1470,8 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
1470 cat >expect <<-EOF &&
1471 Warning: some commits may have been dropped accidentally.
1472 Dropped commits (newer to older):
1472 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1473 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
1473 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1474 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~2)
1475 To avoid this message, use "drop" to explicitly remove a commit.
1476
1477 Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1512,11 +1513,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ig
1513
1514 test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
1515 cat >expect <<-EOF &&
1515 - error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
1516 + error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1517 Warning: some commits may have been dropped accidentally.
1518 Dropped commits (newer to older):
1518 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1519 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
1519 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1520 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1521 To avoid this message, use "drop" to explicitly remove a commit.
1522 EOF
1523 head -n4 expect >expect.2 &&
@@ -1546,11 +1547,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
1547
1548 test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
1549 cat >expect <<-EOF &&
1549 - error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
1550 + error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1551 Warning: some commits may have been dropped accidentally.
1552 Dropped commits (newer to older):
1552 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1553 - - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
1553 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1554 + - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1555 To avoid this message, use "drop" to explicitly remove a commit.
1556
1557 Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1635,7 +1636,7 @@ test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and e
1636 (
1637 set_cat_todo_editor &&
1638 test_must_fail git rebase -i --exec "git show HEAD" \
1638 - --autosquash master >actual
1639 + --autosquash primary >actual
1640 ) &&
1641 test_cmp expected actual
1642 '
@@ -1646,7 +1647,7 @@ test_expect_success 'static check of bad command' '
1647 set_fake_editor &&
1648 test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
1649 git rebase -i --root 2>actual &&
1649 - test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" \
1650 + test_i18ngrep "badcmd $(git rev-list --oneline -1 primary~1)" \
1651 actual &&
1652 test_i18ngrep "You can fix this with .git rebase --edit-todo.." \
1653 actual &&
@@ -1798,13 +1799,13 @@ test_expect_success 'todo has correct onto hash' '
1799 '
1800
1801 test_expect_success 'ORIG_HEAD is updated correctly' '
1801 - test_when_finished "git checkout master && git branch -D test-orig-head" &&
1802 + test_when_finished "git checkout primary && git branch -D test-orig-head" &&
1803 git checkout -b test-orig-head A &&
1804 git commit --allow-empty -m A1 &&
1805 git commit --allow-empty -m A2 &&
1806 git commit --allow-empty -m A3 &&
1807 git commit --allow-empty -m A4 &&
1807 - git rebase master &&
1808 + git rebase primary &&
1809 test_cmp_rev ORIG_HEAD test-orig-head@{1}
1810 '
1811