{"thread":{"id":"13268","subject":"[PATCH] rev-parse: fix --verify to error out when passed junk after a good rev","startedAt":"2008-04-26T13:19:29Z","lastAt":"2008-04-27T06:21:26Z","messageCount":2,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75218","messageId":"20080426151929.819ced3e.chriscool@tuxfamily.org","threadId":"13268","inReplyTo":null,"subject":"[PATCH] rev-parse: fix --verify to error out when passed junk after a good rev","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-04-26T13:19:29Z","receivedAt":"2008-04-26T13:19:29Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Before this patch something like:\n\n$ git rev-parse --verify <good-rev> <junk>\n\nworked whatever junk was as long as <good-rev> could be parsed\ncorrectly.\n\nThis patch makes \"git rev-parse --verify\" error out when passed\nany junk after a good rev.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin-rev-parse.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\n\tWith this patch something like:\n\n\t$ git rev-parse --verify <good1> <good2>\n\n\twill still fail.\n\n\tFor example:\n\n\t$ git rev-parse --verify v1.5.5 v1.4.0\n\t9d831805195ba40b62f632acc6bb6e53d3ec9ee1\n\t120530fb2e10679d9095e278c95c0e98c96f3080\n\tfatal: Needed a single revision\n\n\tbut it failed like that before.\n\n\tI don't know if I should make it work.  \n\ndiff --git a/builtin-rev-parse.c b/builtin-rev-parse.c\nindex 9384a99..0e59707 100644\n--- a/builtin-rev-parse.c\n+++ b/builtin-rev-parse.c\n@@ -576,11 +576,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\tshow_rev(REVERSED, sha1, arg+1);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (verify)\n+\t\t\tdie_no_single_rev(quiet);\n \t\tas_is = 1;\n \t\tif (!show_file(arg))\n \t\t\tcontinue;\n-\t\tif (verify)\n-\t\t\tdie_no_single_rev(quiet);\n \t\tverify_filename(prefix, arg);\n \t}\n \tshow_default();\n-- \n1.5.5.1.164.g3d51ee.dirty\n"},{"id":"75264","messageId":"7v63u3izrt.fsf@gitster.siamese.dyndns.org","threadId":"13268","inReplyTo":"20080426151929.819ced3e.chriscool@tuxfamily.org","subject":"Re: [PATCH] rev-parse: fix --verify to error out when passed junk after a good rev","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-27T06:21:26Z","receivedAt":"2008-04-27T06:21:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> Before this patch something like:\n>\n> $ git rev-parse --verify <good-rev> <junk>\n>\n> worked whatever junk was as long as <good-rev> could be parsed\n> correctly.\n>\n> This patch makes \"git rev-parse --verify\" error out when passed\n> any junk after a good rev.\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  builtin-rev-parse.c |    4 ++--\n>  1 files changed, 2 insertions(+), 2 deletions(-)\n>\n> \tWith this patch something like:\n>\n> \t$ git rev-parse --verify <good1> <good2>\n>\n> \twill still fail.\n\nI think this should fail.\n\nI've long thought that ideally giving anything but a single good rev to\n\"rev-parse --verify\" should fail before spitting anything out.  This, like\nother reponses to errorneous inputs, were what we considered of lower\npriority in early days of git (think \"before the end of 2005\"), because we\nhad many other \"better and more urgent\" things to worry about.  I think we\nhave long passed that stage.\n"}]}