X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=rev-parse.c;h=7f66ae2db827c6ce0ee245ac416d2e80a937061f;hb=b176e6ba5bc37466ffcb6c8c0f38c47ec6e9e73a;hp=e956cd5ed54906335f0b07e9b522a869bfddd218;hpb=7941602983f68e2cddafca5a2da8215d1271742b;p=git.git diff --git a/rev-parse.c b/rev-parse.c index e956cd5e..7f66ae2d 100644 --- a/rev-parse.c +++ b/rev-parse.c @@ -160,6 +160,14 @@ static int show_file(const char *arg) return 0; } +static void die_badfile(const char *arg) +{ + if (errno != ENOENT) + die("'%s': %s", arg, strerror(errno)); + die("'%s' is ambiguous - revision name or file/directory name?\n" + "Please put '--' before the list of filenames.", arg); +} + int main(int argc, char **argv) { int i, as_is = 0, verify = 0; @@ -176,7 +184,7 @@ int main(int argc, char **argv) if (as_is) { if (show_file(arg) && as_is < 2) if (lstat(arg, &st) < 0) - die("'%s': %s", arg, strerror(errno)); + die_badfile(arg); continue; } if (!strcmp(arg,"-n")) { @@ -343,7 +351,7 @@ int main(int argc, char **argv) if (verify) die("Needed a single revision"); if (lstat(arg, &st) < 0) - die("'%s': %s", arg, strerror(errno)); + die_badfile(arg); } show_default(); if (verify && revs_count != 1)