rev/path disambiguation: further restrict "misspelled index entry" diag

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>

Junio C Hamano committed May 10, 2011 at 12:05 UTC 0e539dca51c298ca2ee102e0ca118797f2da99eb
1 file changed +11 -2
setup.c
+11 -2
@@ -85,8 +85,17 @@ static void NORETURN die_verify_filename(const char *prefix, const char *arg)
85 {
86 unsigned char sha1[20];
87 unsigned mode;
88 - /* try a detailed diagnostic ... */
89 - get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
88 +
89 + /*
90 + * Saying "'(icase)foo' does not exist in the index" when the
91 + * user gave us ":(icase)foo" is just stupid. A magic pathspec
92 + * begins with a colon and is followed by a non-alnum; do not
93 + * let get_sha1_with_mode_1(only_to_die=1) to even trigger.
94 + */
95 + if (!(arg[0] == ':' && !isalnum(arg[1])))
96 + /* try a detailed diagnostic ... */
97 + get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
98 +
99 /* ... or fall back the most general message. */
100 die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
101 "Use '--' to separate paths from revisions", arg);