Skip to content

Commit

Permalink
rev/path disambiguation: further restrict "misspelled index entry" diag
Browse files Browse the repository at this point in the history
A colon followed by anything !isalnum() (e.g. ":/heh") at this point is
known not to be an existing rev.  Just give a generic "neither a rev nor
a path" error message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 10, 2011
1 parent 2e83b66 commit 0e539dc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,17 @@ static void NORETURN die_verify_filename(const char *prefix, const char *arg)
{
unsigned char sha1[20];
unsigned mode;
/* try a detailed diagnostic ... */
get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);

/*
* Saying "'(icase)foo' does not exist in the index" when the
* user gave us ":(icase)foo" is just stupid. A magic pathspec
* begins with a colon and is followed by a non-alnum; do not
* let get_sha1_with_mode_1(only_to_die=1) to even trigger.
*/
if (!(arg[0] == ':' && !isalnum(arg[1])))
/* try a detailed diagnostic ... */
get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);

/* ... or fall back the most general message. */
die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
"Use '--' to separate paths from revisions", arg);
Expand Down

0 comments on commit 0e539dc

Please sign in to comment.