summaryrefslogtreecommitdiff
path: root/builtin/ls-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-08-23 15:34:31 -0700
committerJunio C Hamano <gitster@pobox.com>2011-08-23 15:34:31 -0700
commit6133e4da549efbda98565163705af0781b096a4c (patch)
treec1927b6f9096f182bd48c66fb91e93c616f2b29e /builtin/ls-files.c
parentd0b46502de2893a121427b94321a2bfc8cffde27 (diff)
parent0f64bfa9567f697d6152ef9ea937d4b573029a08 (diff)
downloadgit-6133e4da549efbda98565163705af0781b096a4c.tar.gz
Merge branch 'cb/maint-ls-files-error-report'
* cb/maint-ls-files-error-report: ls-files: fix pathspec display on error
Diffstat (limited to 'builtin/ls-files.c')
-rw-r--r--builtin/ls-files.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 0e98bff0c4..e8a800d3ac 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -353,11 +353,13 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
}
}
-int report_path_error(const char *ps_matched, const char **pathspec, int prefix_len)
+int report_path_error(const char *ps_matched, const char **pathspec, const char *prefix)
{
/*
* Make sure all pathspec matched; otherwise it is an error.
*/
+ struct strbuf sb = STRBUF_INIT;
+ const char *name;
int num, errors = 0;
for (num = 0; pathspec[num]; num++) {
int other, found_dup;
@@ -382,10 +384,12 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_
if (found_dup)
continue;
+ name = quote_path_relative(pathspec[num], -1, &sb, prefix);
error("pathspec '%s' did not match any file(s) known to git.",
- pathspec[num] + prefix_len);
+ name);
errors++;
}
+ strbuf_release(&sb);
return errors;
}
@@ -577,7 +581,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (ps_matched) {
int bad;
- bad = report_path_error(ps_matched, pathspec, prefix_len);
+ bad = report_path_error(ps_matched, pathspec, prefix);
if (bad)
fprintf(stderr, "Did you forget to 'git add'?\n");