@matheusbsbs / matheus-bagliano / commits / 93e23fea2d
Fork 0

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>

Junio C Hamano committed Aug 29, 2007 at 23:12 UTC 93e23fea2d7538ac24e35b50984dbbbb84d89f9a
1 file changed +20
builtin-ls-files.c
+20
@@ -511,8 +511,28 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
511 */
512 int num, errors = 0;
513 for (num = 0; pathspec[num]; num++) {
514 + int other, found_dup;
515 +
516 if (ps_matched[num])
517 continue;
518 + /*
519 + * The caller might have fed identical pathspec
520 + * twice. Do not barf on such a mistake.
521 + */
522 + for (found_dup = other = 0;
523 + !found_dup && pathspec[other];
524 + other++) {
525 + if (other == num || !ps_matched[other])
526 + continue;
527 + if (!strcmp(pathspec[other], pathspec[num]))
528 + /*
529 + * Ok, we have a match already.
530 + */
531 + found_dup = 1;
532 + }
533 + if (found_dup)
534 + continue;
535 +
536 error("pathspec '%s' did not match any file(s) known to git.",
537 pathspec[num] + prefix_offset);
538 errors++;