t3404 (rebase -i): introduce helper to check position of HEAD
The same code to check the position of HEAD is used by several tests in this script. Factor it out as a function and simplify it. Noticed using an &&-chaining tester, because the current code does not propagate the precise exit status from errors. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Oct 31, 2010 at 02:40 UTC
5c947e2c386aea5c94546c7a40a0d4d7f7b3934a
1 file changed
+9
-15
t/t3404-rebase-interactive.sh
+9
-15
@@ -29,6 +29,12 @@ Initial setup:
29
30
. "$TEST_DIRECTORY"/lib-rebase.sh
31
32
+test_cmp_rev () {
33
+ git describe --always --tags "$1" >expect.rev &&
34
+ git describe --always --tags "$2" >actual.rev &&
35
+ test_cmp expect.rev actual.rev
36
+}
37
+
38
set_fake_editor
39
40
# WARNING: Modifications to the initial repository can change the SHA ID used
@@ -80,20 +86,12 @@ test_expect_success 'rebase -i with the exec command' '
86
test_path_is_file touch-one &&
87
test_path_is_file touch-two &&
88
test_path_is_missing touch-three " (should have stopped before)" &&
83
- test $(git rev-parse C) = $(git rev-parse HEAD) || {
84
- echo "Stopped at wrong revision:"
85
- echo "($(git describe --tags HEAD) instead of C)"
86
- false
87
- } &&
89
+ test_cmp_rev C HEAD &&
90
git rebase --continue &&
91
test_path_is_file touch-three &&
92
test_path_is_file "touch-file name with spaces" &&
93
test_path_is_file touch-after-semicolon &&
92
- test $(git rev-parse master) = $(git rev-parse HEAD) || {
93
- echo "Stopped at wrong revision:"
94
- echo "($(git describe --tags HEAD) instead of master)"
95
- false
96
- } &&
94
+ test_cmp_rev master HEAD &&
95
rm -f touch-*
96
'
97
@@ -114,11 +112,7 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
112
export FAKE_LINES &&
113
test_must_fail git rebase -i HEAD^
114
) &&
117
- test $(git rev-parse master^) = $(git rev-parse HEAD) || {
118
- echo "Stopped at wrong revision:"
119
- echo "($(git describe --tags HEAD) instead of master^)"
120
- false
121
- } &&
115
+ test_cmp_rev master^ HEAD &&
116
git reset --hard &&
117
git rebase --continue
118
'