summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-10 19:05:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-10 19:38:06 (GMT)
commit0e539dca51c298ca2ee102e0ca118797f2da99eb (patch)
tree3844b41b9c9c8342c58e735c18ac1a47618f6347 /setup.c
parent2e83b66c32c1d482575fd8caed80680a2f69c5f1 (diff)
downloadgit-0e539dca51c298ca2ee102e0ca118797f2da99eb.zip
git-0e539dca51c298ca2ee102e0ca118797f2da99eb.tar.gz
git-0e539dca51c298ca2ee102e0ca118797f2da99eb.tar.bz2
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>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/setup.c b/setup.c
index 7fde4fa..fd4ce59 100644
--- a/setup.c
+++ b/setup.c
@@ -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);