git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* surprising error message in parse_opt_with_commit
@ 2009-08-06 19:27 Tim Harper
  2009-08-06 19:34 ` Shawn O. Pearce
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Harper @ 2009-08-06 19:27 UTC (permalink / raw)
  To: git

When I typed 'git branch --contains efabdfb' on a machine today, I was
surprised to receive this error message: "error: malformed object name
efabdfb"

I would have expected instead to receive the message: "no such commit: efabdfb".

I went hunting through the source code and found the origination point
of the error:

/parse-options.c
 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.

Am I off base here?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-08-07  5:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 19:27 surprising error message in parse_opt_with_commit Tim Harper
2009-08-06 19:34 ` Shawn O. Pearce
2009-08-06 19:53   ` [PATCH] clarify error message when an abbreviated non-existent commit was specified Tim Harper
2009-08-07  5:17     ` Tim Harper
2009-08-07  5:36       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).