X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fls-files.c;h=468bb13c81b960ac5c9ad5b37cca3ac37b6ef5c0;hb=701825de23da2bff6c784d33ff27f75e802abd81;hp=15701233e29b240cfa1abdb56bd489306e74c677;hpb=2765233c64c35eb43a8b46c377fb8b464469221f;p=git.git 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");