Merge branch 'cb/maint-ls-files-error-report'

* cb/maint-ls-files-error-report:
  ls-files: fix pathspec display on error
This commit is contained in:
Junio C Hamano
2011-08-23 15:34:31 -07:00
6 changed files with 88 additions and 10 deletions

View File

@ -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");