Re: [PATCH] unpack-trees: do not set SKIP_WORKTREE on submodules
From: Elijah Newren <hidden>
Date: 2020-06-18 19:20:03
On Thu, Jun 18, 2020 at 7:34 AM Matheus Tavares Bernardino [off-list ref] wrote:
On Wed, Jun 17, 2020 at 9:24 PM Elijah Newren [off-list ref] wrote:quoted
If someone were to try do change their sparsity patterns or even just run a "git sparse-checkout reapply" when they had the above issues, they'd see something like: $ git sparse-checkout reapply warning: The following paths are unmerged and were left despite sparse patterns: filename_with_conflicts After fixing the above paths, you may want to run `git sparse-checkout reapply`. This basically suggests that we consider uncommitted and unmerged files to be "unclean" in some way (sparse-checkout wants to set the SKIP_WORKTREE bit on all files that do not match the sparsity specification, so "clean" means sparse-checkout is able to do so). So I could amend my earlier comparison and say that IF the user has a clean directory, then "git grep --recurse-submodules $REVISION $PATTERN" should be equivalent to "git checkout $REVISION && git grep --recurse-submodules $PATTERN". I could also say that given the big warnings we give users when we can't set the SKIP_WORKTREE bit, that we expect it to be a transient state and thus that we expect them to more likely than not clear it out by the time they do switch branches. That would lead us to the follow-up rule that if the user does not have a clean directory then "git grep --recurse-submodules $REVISION $PATTERN" should be equivalent to what you would get if the unclean entries were ignored (expecting them to be cleaned before the any `git checkout` could be run) and you then otherwise ran "git checkout $REVISION && git grep --recurse-submodules $PATTERN".Makes sense, thanks! We haven't mentioned "git grep --cached" yet, but it would behave in the same way of the worktree grep, in this case. (I.e. searching the submodules, as their SKIP_WORTREE bit was not set.) So I guess it should be fine, as well.
:-)
quoted
That suggests that grep's implementation we agreed on earlier is still correct (when given a $REVISION ignore submodulees that do not match the sparsity patterns), but that unpack-trees/sparse-checkout still need an update: When we notice an initialized submodule that does not match the sparsity patterns, we should print a warning just like we do for unmerged and dirty entries.Yeah, seems like a good approach. Thanks for the explanations. Some of the test cases in mt/grep-sparse-checkout will have to be adjusted with this change. Should I reroll the series based on the patch you will send or do you prefer to adjust them in your patch (and make it dependent on mt/grep-sparse-checkout)?
Ah, good catch. Your series came first, is longer, and is reviewed other than the submodule/config stuff that needs someone more familiar with that area than me. Since my patch needs more work anyway, how about I rebase my patch on top of your work, and make sure to ping you as a reviewer to make sure I don't mess anything up? Thanks, Elijah