{"thread":{"id":"20446","subject":"Re: surprising error message in parse_opt_with_commit","startedAt":"2009-08-06T19:41:53Z","lastAt":"2009-08-06T19:41:53Z","messageCount":1,"participants":["Tim Harper"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119822","messageId":"e1a5e9a00908061241g43108278tb37f2982056ada81@mail.gmail.com","threadId":"20446","inReplyTo":null,"subject":"Re: surprising error message in parse_opt_with_commit","fromName":"Tim Harper","fromEmail":"timcharper@gmail.com","sentAt":"2009-08-06T19:41:53Z","receivedAt":"2009-08-06T19:41:53Z","isPatch":false,"sender":{"key":"timcharper@gmail.com","avatar":"https://gravatar.com/avatar/1a2e0c06c7862ff065ee6b1d53195333a5a0577c040ecb2856a150d8e0b00ecd?d=mp&s=160"},"body":"On Thu, Aug 6, 2009 at 1:34 PM, Shawn O. Pearce<spearce@spearce.org> wrote:\n> Tim Harper <timcharper@gmail.com> wrote:\n>>  610 int parse_opt_with_commit(const struct option *opt, const char\n>> *arg, int unset)\n>>  611 {\n>>  612  unsigned char sha1[20];\n>>  613  struct commit *commit;\n>>  614\n>>  615  if (!arg)\n>>  616          return -1;\n>>  617  if (get_sha1(arg, sha1))\n>>  618          return error(\"malformed object name %s\", arg);\n>>  619  commit = lookup_commit_reference(sha1);\n>>  620  if (!commit)\n>>  621          return error(\"no such commit %s\", arg);\n>>  622  commit_list_insert(commit, opt->value);\n>>  623  return 0;\n>>  624 }\n>>\n>> It appears the get_sha1 call is returning true, causing the 'malformed\n>> object name' error to be returned.  However, it seems that ideally\n>> since efabdfb is not malformed (it would be a valid ref if it\n>> existed), the execution path should continue to line 619, receive no\n>> commit, and fail on 621.\n>\n> get_sha1 is responsible for expanding an abbreviated ID to the\n> full ID.  If it can't do the expansion, it errors out.  The code\n> is correct as-is, though the error message on 618 is a bit odd.\n>\n> --\n> Shawn.\n>\n\nok, that makes more sense.  I notice if I pass a full, mutated\n40-character sha1 commit, I get the error message I expect.\n"}]}