t4041 (diff-submodule-option): parse digests sensibly
`git rev-list --max-count=1 HEAD` is a roundabout way of saying `git rev-parse --verify HEAD`; replace a bunch of instances of the former with the latter. Also, don't unnecessarily `cut -c1-7` the rev-parse output when the `--short` option is available. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramkumar Ramachandra committed
Nov 30, 2012 at 17:07 UTC
20fa53855e5479e9903047ba18cc247fd4519db4
1 file changed
+7
-7
t/t4041-diff-submodule-option.sh
+7
-7
@@ -21,7 +21,7 @@ add_file () {
21
test_tick &&
22
git commit -m "Add $name"
23
done >/dev/null
24
- git rev-parse --verify HEAD | cut -c1-7
24
+ git rev-parse --short --verify HEAD
25
cd "$owd"
26
}
27
commit_file () {
@@ -33,7 +33,7 @@ test_create_repo sm1 &&
33
add_file . foo >/dev/null
34
35
head1=$(add_file sm1 foo1 foo2)
36
-fullhead1=$(cd sm1; git rev-list --max-count=1 $head1)
36
+fullhead1=$(cd sm1; git rev-parse --verify HEAD)
37
38
test_expect_success 'added submodule' "
39
git add sm1 &&
@@ -116,8 +116,8 @@ EOF
116
test_cmp expected actual
117
"
118
119
-fullhead2=$(cd sm1; git rev-list --max-count=1 $head2)
119
test_expect_success 'modified submodule(forward) --submodule=short' "
120
+fullhead2=$(cd sm1; git rev-parse --verify HEAD)
121
git diff --submodule=short >actual &&
122
cat >expected <<-EOF &&
123
diff --git a/sm1 b/sm1
@@ -135,7 +135,7 @@ commit_file sm1 &&
135
head3=$(
136
cd sm1 &&
137
git reset --hard HEAD~2 >/dev/null &&
138
- git rev-parse --verify HEAD | cut -c1-7
138
+ git rev-parse --short --verify HEAD
139
)
140
141
test_expect_success 'modified submodule(backward)' "
@@ -220,8 +220,8 @@ EOF
220
rm -f sm1 &&
221
test_create_repo sm1 &&
222
head6=$(add_file sm1 foo6 foo7)
223
-fullhead6=$(cd sm1; git rev-list --max-count=1 $head6)
223
test_expect_success 'nonexistent commit' "
224
+fullhead6=$(cd sm1; git rev-parse --verify HEAD)
225
git diff-index -p --submodule=log HEAD >actual &&
226
cat >expected <<-EOF &&
227
Submodule sm1 $head4...$head6 (commits not present)
@@ -318,8 +318,8 @@ EOF
318
"
319
320
(cd sm1; git commit -mchange foo6 >/dev/null) &&
321
-head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
321
test_expect_success 'submodule is modified' "
322
+head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
323
git diff-index -p --submodule=log HEAD >actual &&
324
cat >expected <<-EOF &&
325
Submodule sm1 $head6..$head8:
@@ -461,7 +461,7 @@ EOF
461
test_cmp expected actual
462
"
463
464
-fullhead7=$(cd sm2; git rev-list --max-count=1 $head7)
464
+fullhead7=$(cd sm2; git rev-parse --verify HEAD)
465
466
test_expect_success 'given commit --submodule=short' "
467
git diff-index -p --submodule=short HEAD^ >actual &&