Skip to content

Commit 780308d

Browse files
phillipwoodgitster
authored andcommitted
t3404: use test_cmp_rev
There are a number of places where we compare two revisions with test $(git rev-parse rev1) = $(git rev-parse rev2) when these fail there's no indication what has gone wrong and you need to be running with `-x` to see where the test has failed. Lets use test_cmp_rev instead. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 083378c commit 780308d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

t/t3404-rebase-interactive.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ test_expect_success 'no changes are a nop' '
186186
git checkout branch2 &&
187187
git rebase -i F &&
188188
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
189-
test $(git rev-parse I) = $(git rev-parse HEAD)
189+
test_cmp_rev I HEAD
190190
'
191191

192192
test_expect_success 'test the [branch] option' '
@@ -195,16 +195,16 @@ test_expect_success 'test the [branch] option' '
195195
git commit -m "stop here" &&
196196
git rebase -i F branch2 &&
197197
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
198-
test $(git rev-parse I) = $(git rev-parse branch2) &&
199-
test $(git rev-parse I) = $(git rev-parse HEAD)
198+
test_cmp_rev I branch2 &&
199+
test_cmp_rev I HEAD
200200
'
201201

202202
test_expect_success 'test --onto <branch>' '
203203
git checkout -b test-onto branch2 &&
204204
git rebase -i --onto branch1 F &&
205205
test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
206-
test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
207-
test $(git rev-parse I) = $(git rev-parse branch2)
206+
test_cmp_rev HEAD^ branch1 &&
207+
test_cmp_rev I branch2
208208
'
209209

210210
test_expect_success 'rebase on top of a non-conflicting commit' '
@@ -213,12 +213,12 @@ test_expect_success 'rebase on top of a non-conflicting commit' '
213213
git rebase -i branch2 &&
214214
test file6 = $(git diff --name-only original-branch1) &&
215215
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
216-
test $(git rev-parse I) = $(git rev-parse branch2) &&
217-
test $(git rev-parse I) = $(git rev-parse HEAD~2)
216+
test_cmp_rev I branch2 &&
217+
test_cmp_rev I HEAD~2
218218
'
219219

220220
test_expect_success 'reflog for the branch shows state before rebase' '
221-
test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
221+
test_cmp_rev branch1@{1} original-branch1
222222
'
223223

224224
test_expect_success 'reflog for the branch shows correct finish message' '
@@ -278,7 +278,7 @@ test_expect_success 'show conflicted patch' '
278278

279279
test_expect_success 'abort' '
280280
git rebase --abort &&
281-
test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
281+
test_cmp_rev new-branch1 HEAD &&
282282
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
283283
test_path_is_missing .git/rebase-merge
284284
'
@@ -321,7 +321,7 @@ test_expect_success 'retain authorship w/ conflicts' '
321321
echo resolved >conflict &&
322322
git add conflict &&
323323
git rebase --continue &&
324-
test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) &&
324+
test_cmp_rev conflict-a^0 HEAD^ &&
325325
git show >out &&
326326
grep AttributeMe out
327327
'
@@ -338,7 +338,7 @@ test_expect_success 'squash' '
338338
git rebase -i --onto master HEAD~2
339339
) &&
340340
test B = $(cat file7) &&
341-
test $(git rev-parse HEAD^) = $(git rev-parse master)
341+
test_cmp_rev HEAD^ master
342342
'
343343

344344
test_expect_success 'retain authorship when squashing' '
@@ -397,9 +397,9 @@ test_expect_success REBASE_P 'preserve merges with -p' '
397397
git update-index --refresh &&
398398
git diff-files --quiet &&
399399
git diff-index --quiet --cached HEAD -- &&
400-
test $(git rev-parse HEAD~6) = $(git rev-parse branch1) &&
401-
test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) &&
402-
test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) &&
400+
test_cmp_rev HEAD~6 branch1 &&
401+
test_cmp_rev HEAD~4^2 to-be-preserved &&
402+
test_cmp_rev HEAD^^2^ HEAD^^^ &&
403403
test $(git show HEAD~5:file1) = B &&
404404
test $(git show HEAD~3:file1) = C &&
405405
test $(git show HEAD:file1) = E &&
@@ -431,7 +431,7 @@ test_expect_success '--continue tries to commit' '
431431
git add file1 &&
432432
FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
433433
) &&
434-
test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
434+
test_cmp_rev HEAD^ new-branch1 &&
435435
git show HEAD | grep chouette
436436
'
437437

@@ -738,7 +738,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
738738
--author="Somebody else <[email protected]>" &&
739739
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
740740
git rebase -i branch3 &&
741-
test $(git rev-parse branch3) = $(git rev-parse branch4)
741+
test_cmp_rev branch3 branch4
742742
743743
'
744744

@@ -797,7 +797,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
797797
test_must_fail git rebase -i submodule-base &&
798798
git reset &&
799799
git rebase --continue &&
800-
test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
800+
test_cmp_rev submodule-base HEAD
801801
'
802802

803803
test_expect_success 'avoid unnecessary reset' '
@@ -820,7 +820,7 @@ test_expect_success 'reword' '
820820
git rebase -i A &&
821821
git show HEAD | grep "E changed" &&
822822
test $(git rev-parse master) != $(git rev-parse HEAD) &&
823-
test $(git rev-parse master^) = $(git rev-parse HEAD^) &&
823+
test_cmp_rev master^ HEAD^ &&
824824
FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
825825
git rebase -i A &&
826826
git show HEAD^ | grep "D changed" &&
@@ -884,7 +884,7 @@ test_expect_success 'always cherry-pick with --no-ff' '
884884
git diff HEAD~$p original-no-ff-branch~$p > out &&
885885
test_must_be_empty out
886886
done &&
887-
test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
887+
test_cmp_rev HEAD~3 original-no-ff-branch~3 &&
888888
git diff HEAD~3 original-no-ff-branch~3 > out &&
889889
test_must_be_empty out
890890
'

0 commit comments

Comments
 (0)