Re: surprising error message in parse_opt_with_commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 6, 2009 at 1:34 PM, Shawn O. Pearce<spearce@xxxxxxxxxxx> wrote:
> Tim Harper <timcharper@xxxxxxxxx> wrote:
>>  610 int parse_opt_with_commit(const struct option *opt, const char
>> *arg, int unset)
>>  611 {
>>  612  unsigned char sha1[20];
>>  613  struct commit *commit;
>>  614
>>  615  if (!arg)
>>  616          return -1;
>>  617  if (get_sha1(arg, sha1))
>>  618          return error("malformed object name %s", arg);
>>  619  commit = lookup_commit_reference(sha1);
>>  620  if (!commit)
>>  621          return error("no such commit %s", arg);
>>  622  commit_list_insert(commit, opt->value);
>>  623  return 0;
>>  624 }
>>
>> It appears the get_sha1 call is returning true, causing the 'malformed
>> object name' error to be returned.  However, it seems that ideally
>> since efabdfb is not malformed (it would be a valid ref if it
>> existed), the execution path should continue to line 619, receive no
>> commit, and fail on 621.
>
> get_sha1 is responsible for expanding an abbreviated ID to the
> full ID.  If it can't do the expansion, it errors out.  The code
> is correct as-is, though the error message on 618 is a bit odd.
>
> --
> Shawn.
>

ok, that makes more sense.  I notice if I pass a full, mutated
40-character sha1 commit, I get the error message I expect.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]