Skip to content

Commit cc400f5

Browse files
chriscoolgitster
authored andcommitted
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>
1 parent a3e8267 commit cc400f5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mktag.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
/*
2020
* We refuse to tag something we can't verify. Just because.
2121
*/
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)
2323
{
2424
int ret = -1;
2525
enum object_type type;
2626
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);
2829

2930
if (buffer) {
3031
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);
3233
free(buffer);
3334
}
3435
return ret;

t/t6050-replace.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ test_expect_success 'replace the author' '
7070
git show $HASH2 | grep "O Thor"
7171
'
7272

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+
7385
#
7486
#
7587
test_done

0 commit comments

Comments
 (0)