diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-03-31 14:53:08 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-31 14:53:08 -0700 |
commit | ab0fb57aac6c5b6f074c07c7e2729bcff58cc45d (patch) | |
tree | 5a81d44aadaf33d77f4b05a48cd7a4ca9a9ddae7 /dir.c | |
parent | Merge branch 'ph/push-doc-cas' into maint (diff) | |
parent | report_path_error(): move to dir.c (diff) | |
download | tgif-ab0fb57aac6c5b6f074c07c7e2729bcff58cc45d.tar.xz |
Merge branch 'jc/report-path-error-to-dir' into maint
Code clean-up.
* jc/report-path-error-to-dir:
report_path_error(): move to dir.c
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -377,6 +377,49 @@ int match_pathspec(const struct pathspec *ps, return negative ? 0 : positive; } +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; +} + /* * Return the length of the "simple" part of a path match limiter. */ |