aboutsummaryrefslogtreecommitdiff
path: root/builtin/ls-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-09-23 14:30:49 -0700
committerJunio C Hamano <gitster@pobox.com>2011-09-23 14:30:49 -0700
commita0b1cb60ab296476084b3d4766a943e2d62719b8 (patch)
tree76ae24f6eb6c2c7488e0c9ae7851ae378d614c3d /builtin/ls-files.c
parent85b3c75f4fd3aa4da976bac702827dc8d7d1bf15 (diff)
parent385ceec1cb46f8a476fa11ffc853dedba512fd52 (diff)
downloadgit-a0b1cb60ab296476084b3d4766a943e2d62719b8.tar.gz
git-a0b1cb60ab296476084b3d4766a943e2d62719b8.tar.xz
Merge branch 'cb/maint-ls-files-error-report' into maint
* cb/maint-ls-files-error-report: t3005: do not assume a particular order of stdout and stderr of git-ls-files 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 15701233e..468bb13c8 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -388,11 +388,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;
@@ -417,10 +419,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;
}
@@ -611,7 +615,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");