]> git.ipfire.org Git - thirdparty/git.git/commit
grep: demonstrate bug with textconv attributes and submodules
authorMatheus Tavares <matheus.bernardino@usp.br>
Wed, 29 Sep 2021 12:24:25 +0000 (09:24 -0300)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Sep 2021 20:19:38 +0000 (13:19 -0700)
commit45bde58ef8f521e7deb730ffe90040b58d11af64
treea4f039975ef49bcf08fefc5c802d89b92d9add2a
parentcefe983a320c03d7843ac78e73bd513a27806845
grep: demonstrate bug with textconv attributes and submodules

In some circumstances, "git grep --textconv --recurse-submodules"
ignores the textconv attributes from the submodules and erroneously
applies the attributes defined in the superproject on the submodules'
files. The textconv cache is also saved on the superproject, even for
submodule objects.

A fix for these problems will probably require at least three changes:

- Some textconv and attributes functions (as well as their callees) will
  have to be adjusted to work with arbitrary repositories. Note that
  "fill_textconv()", for example, already receives a "struct repository"
  but it writes the textconv cache using "write_loose_object()", which
  implicitly works on "the_repository".

- grep.c functions will have to call textconv/userdiff routines passing
  the "repo" field from "struct grep_source" instead of the one from
  "struct grep_opt". The latter always points to "the_repository" on
  "git grep" executions (see its initialization in builtin/grep.c), but
  the former points to the correct repository that each source (an
  object, file, or buffer) comes from.

- "userdiff_find_by_path()" might need to use a different attributes
  stack for each repository it works on or reset its internal static
  stack when the repository is changed throughout the calls.

For now, let's add some tests to demonstrate these problems, and also
update a NEEDSWORK comment in grep.h that mentions this bug to reference
the added tests.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.h
t/t7814-grep-recurse-submodules.sh