Thread (6 messages) 6 messages, 3 authors, 2020-06-18

Re: [PATCH] unpack-trees: do not set SKIP_WORKTREE on submodules

From: Matheus Tavares Bernardino <hidden>
Date: 2020-06-18 14:34:30

On Wed, Jun 17, 2020 at 9:24 PM Elijah Newren [off-list ref] wrote:
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.
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)?

Thanks,
Matheus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help