Skip to content

Commit

Permalink
git grep shows the same hit repeatedly for unmerged paths
Browse files Browse the repository at this point in the history
When the index is unmerged, e.g.

	$ git ls-files -u
        100644 faf413748eb6ccb15161a212156c5e348302b1b6 1	setup.c
        100644 145eca50f41d811c4c8fcb21ed2604e6b2971aba 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>
  • Loading branch information
Junio C Hamano committed Dec 6, 2007
1 parent 9d25acc commit 6326cee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions builtin-grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
memcpy(name + 2, ce->name, len + 1);
}
argv[argc++] = name;
if (argc < MAXARGS)
continue;
status = flush_grep(opt, argc, nr, argv, &kept);
if (0 < status)
hit = 1;
argc = nr + kept;
if (MAXARGS <= argc) {
status = flush_grep(opt, argc, nr, argv, &kept);
if (0 < status)
hit = 1;
argc = nr + kept;
}
if (ce_stage(ce)) {
do {
i++;
Expand Down

0 comments on commit 6326cee

Please sign in to comment.