mktag: call "check_sha1_signature" with the replacement sha1
Otherwise we get a "sha1 mismatch" error for replaced objects. Note that I am not sure at all that this is a good change. It may be that we should just refuse to tag a replaced object. But in this case we should probably give a meaningfull error message instead of "sha1 mismatch". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jan 23, 2009 at 10:07 UTC
cc400f50112a58471b992a54b1a05d99a8a82457
2 files changed
+16
-3
mktag.c
+4
-3
@@ -19,16 +19,17 @@
19
/*
20
* We refuse to tag something we can't verify. Just because.
21
*/
22
-static int verify_object(unsigned char *sha1, const char *expected_type)
22
+static int verify_object(const unsigned char *sha1, const char *expected_type)
23
{
24
int ret = -1;
25
enum object_type type;
26
unsigned long size;
27
- void *buffer = read_sha1_file(sha1, &type, &size);
27
+ const unsigned char *repl;
28
+ void *buffer = read_sha1_file_repl(sha1, &type, &size, &repl);
29
30
if (buffer) {
31
if (type == type_from_string(expected_type))
31
- ret = check_sha1_signature(sha1, buffer, size, expected_type);
32
+ ret = check_sha1_signature(repl, buffer, size, expected_type);
33
free(buffer);
34
}
35
return ret;
t/t6050-replace.sh
+12
@@ -70,6 +70,18 @@ test_expect_success 'replace the author' '
70
git show $HASH2 | grep "O Thor"
71
'
72
73
+cat >tag.sig <<EOF
74
+object $HASH2
75
+type commit
76
+tag mytag
77
+tagger T A Gger <> 0 +0000
78
+
79
+EOF
80
+
81
+test_expect_success 'tag replaced commit' '
82
+ git mktag <tag.sig >.git/refs/tags/mytag 2>message
83
+'
84
+
85
#
86
#
87
test_done