Skip to content

Commit 692654d

Browse files
avargitster
authored andcommitted
mktag tests: test verify_object() with replaced objects
Add tests to demonstrate what "mktag" does in the face of replaced objects. There was an existing test for replaced objects fed to "mktag" added in cc400f5 (mktag: call "check_sha1_signature" with the replacement sha1, 2009-01-23), but that one only tests a commit->commit mapping. Not a mapping to a different type as like we're also testing for here. We could remove the "mktag" test in t6050-replace.sh now if the created tag wasn't being used by a subsequent "fsck" test. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 30f882c commit 692654d

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

t/t3800-mktag.sh

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ test_expect_mktag_success() {
3838
# for the tag.
3939
test_expect_success 'setup' '
4040
test_commit A &&
41-
head=$(git rev-parse --verify HEAD)
41+
test_commit B &&
42+
head=$(git rev-parse --verify HEAD) &&
43+
head_parent=$(git rev-parse --verify HEAD~) &&
44+
tree=$(git rev-parse HEAD^{tree}) &&
45+
blob=$(git rev-parse --verify HEAD:B.t)
4246
'
4347

4448
############################################################
@@ -180,6 +184,35 @@ tagger . <> 0 +0000
180184
181185
EOF
182186

187+
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
188+
'^error: char7: could not verify object'
189+
190+
############################################################
191+
# 9.5. verify object (hash/type) check -- replacement
192+
193+
test_expect_success 'setup replacement of commit -> commit and tree -> blob' '
194+
git replace $head_parent $head &&
195+
git replace -f $tree $blob
196+
'
197+
198+
cat >tag.sig <<EOF
199+
object $head_parent
200+
type commit
201+
tag mytag
202+
tagger . <> 0 +0000
203+
204+
EOF
205+
206+
test_expect_mktag_success 'tag to a commit replaced by another commit'
207+
208+
cat >tag.sig <<EOF
209+
object $tree
210+
type tree
211+
tag mytag
212+
tagger . <> 0 +0000
213+
214+
EOF
215+
183216
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
184217
'^error: char7: could not verify object'
185218

0 commit comments

Comments
 (0)