{"thread":{"id":"17119","subject":"[RFC/PATCH 7/7] mktag: call \"check_sha1_signature\" with the replacement sha1","startedAt":"2009-01-12T17:51:26Z","lastAt":"2009-01-12T17:51:26Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"100148","messageId":"20090112185126.a3984b7d.chriscool@tuxfamily.org","threadId":"17119","inReplyTo":null,"subject":"[RFC/PATCH 7/7] mktag: call \"check_sha1_signature\" with the replacement sha1","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-01-12T17:51:26Z","receivedAt":"2009-01-12T17:51: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\nWhile at it, this patch makes the first argument of \"verify_object\"\nconst.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n mktag.c            |    7 ++++---\n t/t6050-replace.sh |   11 +++++++++++\n 2 files changed, 15 insertions(+), 3 deletions(-)\n\n\tNote that I am not sure at all that this is a good change.\n\tIt may be that we should just refuse to tag a replaced object. But\n\tin this case we should probably give a meaningfull error message\n\tinstead of \"sha1 mismatch\".\n\n\tOtherwise I checked the 2 other calls to \"check_sha1_signature\" and\n\tthey look like they don't need any change.\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..697e0f6 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -70,6 +70,17 @@ 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 test_done\n-- \n1.6.1.83.g16e5\n"}]}