diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-03-24 14:12:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-24 14:12:10 -0700 |
commit | 777c55a61615837d4391facd75cf334b96635801 (patch) | |
tree | 5c5a3afc4249a24acbb6ea76cb72e53057ce6954 /builtin | |
parent | 282616c72d1d08a77ca4fe1186cb708c38408d87 (diff) | |
download | git-777c55a61615837d4391facd75cf334b96635801.tar.gz |
report_path_error(): move to dir.cjc/report-path-error-to-dir
The expected call sequence is for the caller to use match_pathspec()
repeatedly on a set of pathspecs, accumulating the "hits" in a
separate array, and then call this function to diagnose a pathspec
that never matched anything, as that can indicate a typo from the
command line, e.g. "git commit Maekfile".
Many builtin commands use this function from builtin/ls-files.c,
which is not a very healthy arrangement. ls-files might have been
the first command to feel the need for such a helper, but the need
is shared by everybody who uses the "match and then report" pattern.
Move it to dir.c where match_pathspec() is defined.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/ls-files.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 47c38808a2..47d70b2b9b 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -354,49 +354,6 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix) } } -int report_path_error(const char *ps_matched, - const struct pathspec *pathspec, - const char *prefix) -{ - /* - * Make sure all pathspec matched; otherwise it is an error. - */ - struct strbuf sb = STRBUF_INIT; - int num, errors = 0; - for (num = 0; num < pathspec->nr; num++) { - int other, found_dup; - - if (ps_matched[num]) - continue; - /* - * The caller might have fed identical pathspec - * twice. Do not barf on such a mistake. - * FIXME: parse_pathspec should have eliminated - * duplicate pathspec. - */ - for (found_dup = other = 0; - !found_dup && other < pathspec->nr; - other++) { - if (other == num || !ps_matched[other]) - continue; - if (!strcmp(pathspec->items[other].original, - pathspec->items[num].original)) - /* - * Ok, we have a match already. - */ - found_dup = 1; - } - if (found_dup) - continue; - - error("pathspec '%s' did not match any file(s) known to git.", - pathspec->items[num].original); - errors++; - } - strbuf_release(&sb); - return errors; -} - static const char * const ls_files_usage[] = { N_("git ls-files [options] [<file>...]"), NULL |