Derrick Stolee via GitGitGadget wrote: > diff --git a/repository.h b/repository.h > index c42f7ab6bdc..5315e0852e3 100644 > --- a/repository.h > +++ b/repository.h > @@ -39,6 +39,15 @@ struct repo_settings { > int pack_read_reverse_index; > int pack_use_bitmap_boundary_traversal; > > + /* > + * Has this repository have core.useReplaceRefs=true (on by s/Has/Does(?) It's not a huge deal, but if you were planning to re-roll anyway due to [1], this should be easy enough to include. [1] https://lore.kernel.org/git/a1967c58-48c5-6ae0-f60a-2d8c107f8f66@xxxxxx/ > + * default)? This provides a repository-scoped version of this > + * config, though it could be disabled process-wide via some Git > + * builtins or the --no-replace-objects option. See > + * replace_refs_enabled() for more details. > + */ > + int read_replace_refs; > + > struct fsmonitor_settings *fsmonitor; /* lazily loaded */ > > int index_version; > diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh > index 8143817b19e..d37c83b4640 100755 > --- a/t/t7814-grep-recurse-submodules.sh > +++ b/t/t7814-grep-recurse-submodules.sh > @@ -594,4 +594,44 @@ test_expect_success 'grep partially-cloned submodule' ' > ) > ' > > +test_expect_success 'check scope of core.useReplaceRefs' ' > + git init base && > + git init base/sub && > + > + echo A >base/a && > + echo B >base/b && > + echo C >base/sub/c && > + echo D >base/sub/d && > + > + git -C base/sub add c d && > + git -C base/sub commit -m "Add files" && > + > + git -C base submodule add ./sub && > + git -C base add a b sub && > + git -C base commit -m "Add files and submodule" && > + > + A=$(git -C base rev-parse HEAD:a) && > + B=$(git -C base rev-parse HEAD:b) && > + C=$(git -C base/sub rev-parse HEAD:c) && > + D=$(git -C base/sub rev-parse HEAD:d) && > + > + git -C base replace $A $B && > + git -C base/sub replace $C $D && > + > + test_must_fail git -C base grep --cached --recurse-submodules A && > + test_must_fail git -C base grep --cached --recurse-submodules C && First, we verify that replace refs are enabled on both the superproject and submodule by default (if they are, 'a' has been replaced with 'b' and 'c' has been replaced with 'd')... > + > + git -C base config core.useReplaceRefs false && > + git -C base grep --recurse-submodules A && > + test_must_fail git -C base grep --cached --recurse-submodules C && ...then, if replace refs are disabled in the superproject (but not the submodule), 'b' no longer replaces 'a' but 'd' still replaces 'c'... > + > + git -C base/sub config core.useReplaceRefs false && > + git -C base grep --cached --recurse-submodules A && > + git -C base grep --cached --recurse-submodules C && ...but once replace refs are disabled in the submodule, 'd' no longer replaces 'c', and 'b' still doesn't replace 'a'... > + > + git -C base config --unset core.useReplaceRefs && > + test_must_fail git -C base grep --cached --recurse-submodules A && > + git -C base grep --cached --recurse-submodules C ...and, finally, if we restore the default state in the superproject (replace refs enabled) but not the submodule, 'b' once again replaces 'a', but 'd' still doesn't replace 'c'. Thanks for adding this test! It clearly and thoroughly exercises the updated config behavior. > +' > + > test_done