fix overstrict :<path> diagnosis
Given "git log :", we get a disambiguation message that tries to be helpful and yet totally misses the point, i.e. $ git log : fatal: Path '' does not exist (neither on disk nor in the index). $ git log :/ fatal: Path '/' exists on disk, but not in the index. An empty path nor anything that begins with '/' cannot possibly in the index, and it is wrong to guess that the user might have meant to access such an index entry. It should yield the same error message as "git log '*.c'", i.e. $ git log '*.c' fatal: ambiguous argument '*.c': unknown revision or path not in the working tree. Use '--' to separate paths from revisions Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 10, 2011 at 11:10 UTC
9619617d33c83ad873539384b3cbfd564053be76
1 file changed
+1
-1
sha1_name.c
+1
-1
@@ -1173,7 +1173,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
1173
}
1174
pos++;
1175
}
1176
- if (!gently)
1176
+ if (!gently && name[1] && name[1] != '/')
1177
diagnose_invalid_index_path(stage, prefix, cp);
1178
free(new_path);
1179
return -1;