aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2012-06-18 20:18:21 +0200
committerJunio C Hamano <gitster@pobox.com>2012-06-18 15:21:42 -0700
commit023e37c37780d6a56f2870a979c8eb3a9ee9a44d (patch)
tree74075e3fc2bf0cf4ca3997d1a745948a82c13e89 /builtin
parentd7236c4395a0c8742871a72d920f789b5bd4abf6 (diff)
downloadgit-023e37c37780d6a56f2870a979c8eb3a9ee9a44d.tar.gz
git-023e37c37780d6a56f2870a979c8eb3a9ee9a44d.tar.xz
verify_filename(): ask the caller to chose the kind of diagnosis
verify_filename() can be called in two different contexts. Either we just tried to interpret a string as an object name, and it fails, so we try looking for a working tree file (i.e. we finished looking at revs that come earlier on the command line, and the next argument must be a pathname), or we _know_ that we are looking for a pathname, and shouldn't even try interpreting the string as an object name. For example, with this change, we get: $ git log COPYING HEAD:inexistant fatal: HEAD:inexistant: no such path in the working tree. Use '-- <path>...' to specify paths that do not exist locally. $ git log HEAD:inexistant fatal: Path 'inexistant' does not exist in 'HEAD' Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/reset.c2
-rw-r--r--builtin/rev-parse.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 9ce064ac1..d56555651 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1045,7 +1045,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!seen_dashdash) {
int j;
for (j = i; j < argc; j++)
- verify_filename(prefix, argv[j]);
+ verify_filename(prefix, argv[j], j == i);
}
paths = get_pathspec(prefix, argv + i);
diff --git a/builtin/reset.c b/builtin/reset.c
index 8c2c1d52a..4cc34c908 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -285,7 +285,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
rev = argv[i++];
} else {
/* Otherwise we treat this as a filename */
- verify_filename(prefix, argv[i]);
+ verify_filename(prefix, argv[i], 1);
}
}
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 98d1cbecc..3e2f5bd44 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -486,7 +486,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
if (as_is) {
if (show_file(arg) && as_is < 2)
- verify_filename(prefix, arg);
+ verify_filename(prefix, arg, 0);
continue;
}
if (!strcmp(arg,"-n")) {
@@ -732,7 +732,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
as_is = 1;
if (!show_file(arg))
continue;
- verify_filename(prefix, arg);
+ verify_filename(prefix, arg, 1);
}
if (verify) {
if (revs_count == 1) {