Skip to content

Commit

Permalink
ls-files --error-unmatch: do not barf if the same pattern is given tw…
Browse files Browse the repository at this point in the history
…ice.

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>
  • Loading branch information
Junio C Hamano committed Aug 30, 2007
1 parent 9656153 commit 93e23fe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions builtin-ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 93e23fe

Please sign in to comment.