Skip to content

Commit 6326cee

Browse files
committed
git grep shows the same hit repeatedly for unmerged paths
When the index is unmerged, e.g. $ git ls-files -u 100644 faf413748eb6ccb15161a212156c5e348302b1b6 1 setup.c 100644 145eca5 2 setup.c 100644 cb9558c49b6027bf225ba2a6154c4d2a52bcdbe2 3 setup.c running "git grep" for work tree files repeats hits for each unmerged stage. $ git grep -n -e setup_work_tree -- '*.[ch]' setup.c:209:void setup_work_tree(void) setup.c:209:void setup_work_tree(void) setup.c:209:void setup_work_tree(void) This should fix it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9d25acc commit 6326cee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin-grep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
343343
memcpy(name + 2, ce->name, len + 1);
344344
}
345345
argv[argc++] = name;
346-
if (argc < MAXARGS)
347-
continue;
348-
status = flush_grep(opt, argc, nr, argv, &kept);
349-
if (0 < status)
350-
hit = 1;
351-
argc = nr + kept;
346+
if (MAXARGS <= argc) {
347+
status = flush_grep(opt, argc, nr, argv, &kept);
348+
if (0 < status)
349+
hit = 1;
350+
argc = nr + kept;
351+
}
352352
if (ce_stage(ce)) {
353353
do {
354354
i++;

0 commit comments

Comments
 (0)