Skip to content

Commit 9f41d09

Browse files
committed
Merge branch 'js/t3404-master-to-primary'
A test script got cleaned up and then made not to depend on the value of init.defaultBranch. * js/t3404-master-to-primary: t3404: do not depend on any specific default branch name
2 parents e082a85 + 9c8509a commit 9f41d09

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

t/t3404-rebase-interactive.sh

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Initial setup:
1212
1313
one - two - three - four (conflict-branch)
1414
/
15-
A - B - C - D - E (master)
15+
A - B - C - D - E (primary)
1616
| \
1717
| F - G - H (branch1)
1818
| \
@@ -30,6 +30,7 @@ Initial setup:
3030
. "$TEST_DIRECTORY"/lib-rebase.sh
3131

3232
test_expect_success 'setup' '
33+
git switch -C primary &&
3334
test_commit A file1 &&
3435
test_commit B file1 &&
3536
test_commit C file2 &&
@@ -65,7 +66,7 @@ SHELL=
6566
export SHELL
6667

6768
test_expect_success 'rebase --keep-empty' '
68-
git checkout -b emptybranch master &&
69+
git checkout -b emptybranch primary &&
6970
git commit --allow-empty -m "empty" &&
7071
git rebase --keep-empty -i HEAD~2 &&
7172
git log --oneline >actual &&
@@ -86,7 +87,7 @@ test_expect_success 'rebase -i with empty todo list' '
8687
'
8788

8889
test_expect_success 'rebase -i with the exec command' '
89-
git checkout master &&
90+
git checkout primary &&
9091
(
9192
set_fake_editor &&
9293
FAKE_LINES="1 exec_>touch-one
@@ -103,12 +104,12 @@ test_expect_success 'rebase -i with the exec command' '
103104
test_path_is_file touch-three &&
104105
test_path_is_file "touch-file name with spaces" &&
105106
test_path_is_file touch-after-semicolon &&
106-
test_cmp_rev master HEAD &&
107+
test_cmp_rev primary HEAD &&
107108
rm -f touch-*
108109
'
109110

110111
test_expect_success 'rebase -i with the exec command runs from tree root' '
111-
git checkout master &&
112+
git checkout primary &&
112113
mkdir subdir && (cd subdir &&
113114
set_fake_editor &&
114115
FAKE_LINES="1 exec_>touch-subdir" \
@@ -121,7 +122,7 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
121122
test_expect_success 'rebase -i with exec allows git commands in subdirs' '
122123
test_when_finished "rm -rf subdir" &&
123124
test_when_finished "git rebase --abort ||:" &&
124-
git checkout master &&
125+
git checkout primary &&
125126
mkdir subdir && (cd subdir &&
126127
set_fake_editor &&
127128
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' '
139140
'
140141

141142
test_expect_success 'rebase -i with the exec command checks tree cleanness' '
142-
git checkout master &&
143+
git checkout primary &&
143144
(
144145
set_fake_editor &&
145146
test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" \
146147
git rebase -i HEAD^
147148
) &&
148-
test_cmp_rev master^ HEAD &&
149+
test_cmp_rev primary^ HEAD &&
149150
git reset --hard &&
150151
git rebase --continue
151152
'
@@ -168,7 +169,7 @@ test_expect_success 'rebase -x with newline in command fails' '
168169
'
169170

170171
test_expect_success 'rebase -i with exec of inexistent command' '
171-
git checkout master &&
172+
git checkout primary &&
172173
test_when_finished "git rebase --abort" &&
173174
(
174175
set_fake_editor &&
@@ -259,8 +260,8 @@ test_expect_success 'stop on conflicting pick' '
259260
>>>>>>> $commit (G)
260261
EOF
261262
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)" &&
264265
test_cmp expect .git/rebase-merge/patch &&
265266
test_cmp expect2 file1 &&
266267
test "$(git diff --name-status |
@@ -287,7 +288,7 @@ test_expect_success 'abort' '
287288
test_expect_success 'abort with error when new base cannot be checked out' '
288289
git rm --cached file1 &&
289290
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 &&
291292
test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
292293
output &&
293294
test_i18ngrep "file1" output &&
@@ -301,7 +302,7 @@ test_expect_success 'retain authorship' '
301302
test_tick &&
302303
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
303304
git tag twerp &&
304-
git rebase -i --onto master HEAD^ &&
305+
git rebase -i --onto primary HEAD^ &&
305306
git show HEAD | grep "^Author: Twerp Snog"
306307
'
307308

@@ -336,10 +337,10 @@ test_expect_success 'squash' '
336337
(
337338
set_fake_editor &&
338339
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
340341
) &&
341342
test B = $(cat file7) &&
342-
test_cmp_rev HEAD^ master
343+
test_cmp_rev HEAD^ primary
343344
'
344345

345346
test_expect_success 'retain authorship when squashing' '
@@ -366,12 +367,12 @@ test_expect_failure REBASE_P 'exchange two commits with -p' '
366367
'
367368

368369
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^ &&
370371
: > unrelated-file &&
371372
git add unrelated-file &&
372373
test_tick &&
373374
git commit -m "unrelated" &&
374-
git checkout -b another-branch master &&
375+
git checkout -b another-branch primary &&
375376
echo B > file1 &&
376377
test_tick &&
377378
git commit -m J file1 &&
@@ -394,7 +395,7 @@ test_expect_success REBASE_P 'preserve merges with -p' '
394395
git commit -m M file1 &&
395396
git checkout -b to-be-rebased &&
396397
test_tick &&
397-
git rebase -i -p --onto branch1 master &&
398+
git rebase -i -p --onto branch1 primary &&
398399
git update-index --refresh &&
399400
git diff-files --quiet &&
400401
git diff-index --quiet --cached HEAD -- &&
@@ -437,7 +438,7 @@ test_expect_success '--continue tries to commit' '
437438
'
438439

439440
test_expect_success 'verbose flag is heeded, even after --continue' '
440-
git reset --hard master@{1} &&
441+
git reset --hard primary@{1} &&
441442
test_tick &&
442443
test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
443444
echo resolved > file1 &&
@@ -802,7 +803,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
802803
'
803804

804805
test_expect_success 'avoid unnecessary reset' '
805-
git checkout master &&
806+
git checkout primary &&
806807
git reset --hard &&
807808
test-tool chmtime =123456789 file3 &&
808809
git update-index --refresh &&
@@ -814,14 +815,14 @@ test_expect_success 'avoid unnecessary reset' '
814815
'
815816

816817
test_expect_success 'reword' '
817-
git checkout -b reword-branch master &&
818+
git checkout -b reword-branch primary &&
818819
(
819820
set_fake_editor &&
820821
FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \
821822
git rebase -i A &&
822823
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^ &&
825826
FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
826827
git rebase -i A &&
827828
git show HEAD^ | grep "D changed" &&
@@ -918,7 +919,7 @@ test_expect_success 'rebase-i history with funny messages' '
918919
'
919920

920921
test_expect_success 'prepare for rebase -i --exec' '
921-
git checkout master &&
922+
git checkout primary &&
922923
git checkout -b execute &&
923924
test_commit one_exec main.txt one_exec &&
924925
test_commit two_exec main.txt two_exec &&
@@ -1027,7 +1028,7 @@ test_expect_success 'rebase -i --exec without <CMD>' '
10271028
git reset --hard execute &&
10281029
test_must_fail git rebase -i --exec 2>actual &&
10291030
test_i18ngrep "requires a value" actual &&
1030-
git checkout master
1031+
git checkout primary
10311032
'
10321033

10331034
test_expect_success 'rebase -i --root re-order and drop commits' '
@@ -1079,7 +1080,7 @@ test_expect_success 'rebase -i --root fixup root commit' '
10791080

10801081
test_expect_success 'rebase -i --root reword original root commit' '
10811082
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 &&
10831084
(
10841085
set_fake_editor &&
10851086
FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
@@ -1091,7 +1092,7 @@ test_expect_success 'rebase -i --root reword original root commit' '
10911092

10921093
test_expect_success 'rebase -i --root reword new root commit' '
10931094
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 &&
10951096
(
10961097
set_fake_editor &&
10971098
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' '
12511252
'
12521253

12531254
test_expect_success 'short commit ID setup' '
1254-
test_when_finished "git checkout master" &&
1255+
test_when_finished "git checkout primary" &&
12551256
git checkout --orphan collide &&
12561257
git rm -rf . &&
12571258
(
@@ -1292,7 +1293,7 @@ test_expect_success 'short commit ID collide' '
12921293
t3404_collider sha1:ac4f2ee
12931294
t3404_collider sha256:16697
12941295
EOF
1295-
test_when_finished "reset_rebase && git checkout master" &&
1296+
test_when_finished "reset_rebase && git checkout primary" &&
12961297
git checkout collide &&
12971298
colliding_id=$(test_oid t3404_collision) &&
12981299
hexsz=$(test_oid hexsz) &&
@@ -1416,11 +1417,11 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
14161417

14171418
rebase_setup_and_clean () {
14181419
test_when_finished "
1419-
git checkout master &&
1420+
git checkout primary &&
14201421
test_might_fail git branch -D $1 &&
14211422
test_might_fail git rebase --abort
14221423
" &&
1423-
git checkout -b $1 ${2:-master}
1424+
git checkout -b $1 ${2:-primary}
14241425
}
14251426

14261427
test_expect_success 'drop' '
@@ -1451,7 +1452,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
14511452
cat >expect <<-EOF &&
14521453
Warning: some commits may have been dropped accidentally.
14531454
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)
14551456
To avoid this message, use "drop" to explicitly remove a commit.
14561457
EOF
14571458
test_config rebase.missingCommitsCheck warn &&
@@ -1469,8 +1470,8 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
14691470
cat >expect <<-EOF &&
14701471
Warning: some commits may have been dropped accidentally.
14711472
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)
14741475
To avoid this message, use "drop" to explicitly remove a commit.
14751476
14761477
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
15121513

15131514
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
15141515
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)
15161517
Warning: some commits may have been dropped accidentally.
15171518
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)
15201521
To avoid this message, use "drop" to explicitly remove a commit.
15211522
EOF
15221523
head -n4 expect >expect.2 &&
@@ -1546,11 +1547,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
15461547

15471548
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
15481549
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)
15501551
Warning: some commits may have been dropped accidentally.
15511552
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)
15541555
To avoid this message, use "drop" to explicitly remove a commit.
15551556
15561557
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
16351636
(
16361637
set_cat_todo_editor &&
16371638
test_must_fail git rebase -i --exec "git show HEAD" \
1638-
--autosquash master >actual
1639+
--autosquash primary >actual
16391640
) &&
16401641
test_cmp expected actual
16411642
'
@@ -1646,7 +1647,7 @@ test_expect_success 'static check of bad command' '
16461647
set_fake_editor &&
16471648
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
16481649
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)" \
16501651
actual &&
16511652
test_i18ngrep "You can fix this with .git rebase --edit-todo.." \
16521653
actual &&
@@ -1798,13 +1799,13 @@ test_expect_success 'todo has correct onto hash' '
17981799
'
17991800

18001801
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" &&
18021803
git checkout -b test-orig-head A &&
18031804
git commit --allow-empty -m A1 &&
18041805
git commit --allow-empty -m A2 &&
18051806
git commit --allow-empty -m A3 &&
18061807
git commit --allow-empty -m A4 &&
1807-
git rebase master &&
1808+
git rebase primary &&
18081809
test_cmp_rev ORIG_HEAD test-orig-head@{1}
18091810
'
18101811

0 commit comments

Comments
 (0)