Skip to content

Commit 20fa538

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b13af9 commit 20fa538

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

t/t4041-diff-submodule-option.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ add_file () {
2121
test_tick &&
2222
git commit -m "Add $name"
2323
done >/dev/null
24-
git rev-parse --verify HEAD | cut -c1-7
24+
git rev-parse --short --verify HEAD
2525
cd "$owd"
2626
}
2727
commit_file () {
@@ -33,7 +33,7 @@ test_create_repo sm1 &&
3333
add_file . foo >/dev/null
3434

3535
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)
3737

3838
test_expect_success 'added submodule' "
3939
git add sm1 &&
@@ -116,8 +116,8 @@ EOF
116116
test_cmp expected actual
117117
"
118118

119-
fullhead2=$(cd sm1; git rev-list --max-count=1 $head2)
120119
test_expect_success 'modified submodule(forward) --submodule=short' "
120+
fullhead2=$(cd sm1; git rev-parse --verify HEAD)
121121
git diff --submodule=short >actual &&
122122
cat >expected <<-EOF &&
123123
diff --git a/sm1 b/sm1
@@ -135,7 +135,7 @@ commit_file sm1 &&
135135
head3=$(
136136
cd sm1 &&
137137
git reset --hard HEAD~2 >/dev/null &&
138-
git rev-parse --verify HEAD | cut -c1-7
138+
git rev-parse --short --verify HEAD
139139
)
140140

141141
test_expect_success 'modified submodule(backward)' "
@@ -220,8 +220,8 @@ EOF
220220
rm -f sm1 &&
221221
test_create_repo sm1 &&
222222
head6=$(add_file sm1 foo6 foo7)
223-
fullhead6=$(cd sm1; git rev-list --max-count=1 $head6)
224223
test_expect_success 'nonexistent commit' "
224+
fullhead6=$(cd sm1; git rev-parse --verify HEAD)
225225
git diff-index -p --submodule=log HEAD >actual &&
226226
cat >expected <<-EOF &&
227227
Submodule sm1 $head4...$head6 (commits not present)
@@ -318,8 +318,8 @@ EOF
318318
"
319319

320320
(cd sm1; git commit -mchange foo6 >/dev/null) &&
321-
head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
322321
test_expect_success 'submodule is modified' "
322+
head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
323323
git diff-index -p --submodule=log HEAD >actual &&
324324
cat >expected <<-EOF &&
325325
Submodule sm1 $head6..$head8:
@@ -461,7 +461,7 @@ EOF
461461
test_cmp expected actual
462462
"
463463

464-
fullhead7=$(cd sm2; git rev-list --max-count=1 $head7)
464+
fullhead7=$(cd sm2; git rev-parse --verify HEAD)
465465

466466
test_expect_success 'given commit --submodule=short' "
467467
git diff-index -p --submodule=short HEAD^ >actual &&

0 commit comments

Comments
 (0)