Skip to content

In grep, no adding submodule ODB as alternates

Jonathan Tan git 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 7 repliesIn review
  2. v28 patches 12 repliesSuperseded
  3. v17 patches 26 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8submodule: lazily add submodule ODBs as alternatesobject-file.c submodule.c submodule.h +1 more+41 -10 replies
2/8grep: use submodule-ODB-as-alternate lazy-additionbuiltin/grep.c submodule.c submodule.h+7 -10 replies
3/8grep: typesafe versions of grep_source_initbuiltin/grep.c grep.c grep.h+34 -230 replies
4/8grep: read submodule entry with explicit repobuiltin/grep.c+5 -50 replies
5/8grep: allocate subrepos on heapbuiltin/grep.c+30 -90 replies
6/8grep: add repository to OID grep sourcesbuiltin/grep.c grep.c grep.h+27 -123 replies
7/8submodule-config: pass repo upon blob config readconfig.c config.h submodule-config.c+19 -90 replies
8/8t7814: show lack of alternate ODB-addingt/t7814-grep-recurse-submodules.sh+3 -00 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMatheus Tavares
SeriesR-b R-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/8] In grep, no adding submodule ODB as alternates

Thanks for reviewing, everyone. Here are the requested changes.

Jonathan Tan (8):
submodule: lazily add submodule ODBs as alternates
grep: use submodule-ODB-as-alternate lazy-addition
grep: typesafe versions of grep_source_init
grep: read submodule entry with explicit repo
grep: allocate subrepos on heap
grep: add repository to OID grep sources
submodule-config: pass repo upon blob config read
t7814: show lack of alternate ODB-adding

 builtin/grep.c                     | 64 +++++++++++++++++++-----------
 config.c                           | 20 ++++++----
 config.h                           |  3 ++
 grep.c                             | 51 +++++++++++++++---------
 grep.h                             | 22 ++++++++--
 object-file.c                      |  5 +++
 submodule-config.c                 |  5 ++-
 submodule.c                        | 25 +++++++++++-
 submodule.h                        |  8 ++++
 t/README                           | 10 +++++
 t/t7814-grep-recurse-submodules.sh |  3 ++
 11 files changed, 161 insertions(+), 55 deletions(-)

Range-diff against v2:

1:  5994a517e8 = 1:  5994a517e8 submodule: lazily add submodule ODBs as alternates
2:  31e9b914c4 = 2:  31e9b914c4 grep: use submodule-ODB-as-alternate lazy-addition
3:  aa3f1f3c89 = 3:  aa3f1f3c89 grep: typesafe versions of grep_source_init
4:  050deacfb7 = 4:  050deacfb7 grep: read submodule entry with explicit repo
5:  3f24815224 ! 5:  7d1eeac4b5 grep: allocate subrepos on heap
    @@ builtin/grep.c: static void work_done(struct work_item *w)
     +		repo_clear(repos_to_free[i]);
     +		free(repos_to_free[i]);
     +	}
    -+	free(repos_to_free);
    ++	FREE_AND_NULL(repos_to_free);
     +	repos_to_free_nr = 0;
     +	repos_to_free_alloc = 0;
     +}

6: 50c69a988b ! 6: f362fc278c grep: add repository to OID grep sources
@@ grep.h: struct grep_opt {
+
+ /*
+ * NEEDSWORK: See if we can remove this field, because the repository
-+ * should probably be per-source, not per-repo. This is potentially the
-+ * cause of at least one bug - "git grep" ignoring the textconv
-+ * attributes from submodules. See [1] for more information.
++ * should probably be per-source. That is, grep.c functions using this
++ * field should probably start using "repo" in "struct grep_source"
++ * instead.
++ *
++ * This is potentially the cause of at least one bug - "git grep"
++ * ignoring the textconv attributes from submodules. See [1] for more
++ * information.
+ * [1] https://lore.kernel.org/git/CAHd-oW5iEQarYVxEXoTG-ua2zdoybTrSjCBKtO0YT292fm0NQQ@mail.gmail.com/
+ */
struct repository *repo;
7: 94db10a4e5 ! 7: 8b86618531 submodule-config: pass repo upon blob config read
@@ Commit message
submodule's ODB as an alternate and then reading an object from the_repository.

+ This makes the "grep --recurse-submodules with submodules without
+ .gitmodules in the working tree" test in t7814 work when
+ GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB is true.
+

## config.c ##
@@ config.c: int git_config_from_blob_oid(config_fn_t fn,
const char *name,
void *data)
{
-@@ config.c: static int git_config_from_blob_ref(config_fn_t fn,
+ struct object_id oid;

- if (get_oid(name, &oid) < 0)
+- if (get_oid(name, &oid) < 0)
++ if (repo_get_oid(repo, name, &oid) < 0)
return error(_("unable to resolve config blob '%s'"), name);
- return git_config_from_blob_oid(fn, name, &oid, data);
+ return git_config_from_blob_oid(fn, name, repo, &oid, data);
8: 4a51fcfb77 = 8: 4b3176f99e t7814: show lack of alternate ODB-adding

Signature · 1 line
2.33.0.rc1.237.g0d66db33f3-goog