{"thread":{"id":"17323","subject":"[PATCH 6/7] mktag: call \"check_sha1_signature\" with the replacement sha1","startedAt":"2009-01-23T09:07:26Z","lastAt":"2009-01-23T09:07:26Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"101640","messageId":"20090123100726.b2d803f2.chriscool@tuxfamily.org","threadId":"17323","inReplyTo":null,"subject":"[PATCH 6/7] mktag: call \"check_sha1_signature\" with the replacement sha1","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-01-23T09:07:26Z","receivedAt":"2009-01-23T09:07:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Otherwise we get a \"sha1 mismatch\" error for replaced objects.\n\nNote that I am not sure at all that this is a good change.\nIt may be that we should just refuse to tag a replaced object. But\nin this case we should probably give a meaningfull error message\ninstead of \"sha1 mismatch\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n mktag.c            |    7 ++++---\n t/t6050-replace.sh |   12 ++++++++++++\n 2 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/mktag.c b/mktag.c\nindex ba3d495..ac812e5 100644\n--- a/mktag.c\n+++ b/mktag.c\n@@ -18,16 +18,17 @@\n /*\n  * We refuse to tag something we can't verify. Just because.\n  */\n-static int verify_object(unsigned char *sha1, const char *expected_type)\n+static int verify_object(const unsigned char *sha1, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buffer = read_sha1_file(sha1, &type, &size);\n+\tconst unsigned char *repl;\n+\tvoid *buffer = read_sha1_file_repl(sha1, &type, &size, &repl);\n \n \tif (buffer) {\n \t\tif (type == type_from_string(expected_type))\n-\t\t\tret = check_sha1_signature(sha1, buffer, size, expected_type);\n+\t\t\tret = check_sha1_signature(repl, buffer, size, expected_type);\n \t\tfree(buffer);\n \t}\n \treturn ret;\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex 0a585ec..334aed6 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -70,6 +70,18 @@ test_expect_success 'replace the author' '\n      git show $HASH2 | grep \"O Thor\"\n '\n \n+cat >tag.sig <<EOF\n+object $HASH2\n+type commit\n+tag mytag\n+tagger T A Gger <> 0 +0000\n+\n+EOF\n+\n+test_expect_success 'tag replaced commit' '\n+     git mktag <tag.sig >.git/refs/tags/mytag 2>message\n+'\n+\n #\n #\n test_done\n-- \n1.6.1.231.g9c286\n"}]}