diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-08-29 23:12:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-08-29 23:12:38 -0700 |
commit | 93e23fea2d7538ac24e35b50984dbbbb84d89f9a (patch) | |
tree | 8883596fb446d00073384fc4ada76c5bc570b437 /builtin-ls-files.c | |
parent | 9656153b87d47b34986f2d77eef9199c24cbf9f6 (diff) | |
download | git-93e23fea2d7538ac24e35b50984dbbbb84d89f9a.tar.gz |
ls-files --error-unmatch: do not barf if the same pattern is given twice.
This is most visible when you do "git commit Makefile Makefile"; it
may be a stupid request, but that is not a reason to fail the command.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-ls-files.c')
-rw-r--r-- | builtin-ls-files.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/builtin-ls-files.c b/builtin-ls-files.c index d36181a755..cce17b5ced 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -511,8 +511,28 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) */ int num, errors = 0; for (num = 0; pathspec[num]; 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. + */ + for (found_dup = other = 0; + !found_dup && pathspec[other]; + other++) { + if (other == num || !ps_matched[other]) + continue; + if (!strcmp(pathspec[other], pathspec[num])) + /* + * 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[num] + prefix_offset); errors++; |