grep: fix worktree case in submodules
commit6a289d45c0e5d155f536d7c1f73c3b33690e92c6
authorMatheus Tavares <matheus.bernardino@usp.br>
Tue, 30 Jul 2019 16:53:27 +0000 (30 13:53 -0300)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jul 2019 20:29:54 +0000 (30 13:29 -0700)
tree8df2d2154eb97939bd38f3d9a75b6643faa4b824
parent1feeaaf26bff51996f9f96c6dc41ca0f95ab5fc4
grep: fix worktree case in submodules

Running git-grep with --recurse-submodules results in a cached grep for
the submodules even when --cached is not used. This makes all
modifications in submodules' tracked files be always ignored when
grepping. Solve that making git-grep respect the cached option when
invoking grep_cache() inside grep_submodule(). Also, add tests to
ensure that the desired behavior is performed.

Reported-by: Daniel Zaoui <jackdanielz@eyomi.org>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c
t/t7814-grep-recurse-submodules.sh