Re: [PATCH v3 5/5] config: add setting to ignore sparsity patterns in some cmds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 2, 2020 at 11:40 PM Elijah Newren <newren@xxxxxxxxx> wrote:
>
> On Sun, May 31, 2020 at 9:46 PM Matheus Tavares Bernardino
> <matheus.bernardino@xxxxxx> wrote:
> >
>
> Moving it to grep's manpage seems ideal to me.  grep's behavior should
> be defined in grep's manual.
>
> > sparse.restrictCmds::
> > See complete definition in linkgit:git-config[1]. In grep, the
> > restriction takes effect in three cases: with --cached; when a
> > commit-ish is given; when searching a working tree where some paths
> > excluded by the sparsity patterns are present (e.g. manually created
> > paths or not removed submodules).
>
> That looks more than a little confusing.  Could this definition be
> something more like "See base definition in linkgit:git-config[1].
> grep honors sparse.restrictCmds by limiting searches to the sparsity
> paths in three cases: when searching the working tree, when searching
> the index with --cached, or when searching a specified commit"

Yes, this looks better, thanks. I would only add a brief explanation
on what we mean by limiting the search in the working tree case. Since
the working tree should already contain only the sparse paths (in most
cases), I think this sentence may sound a little confusing without
some explanation. Even further, some users might expect that `git -c
sparse.restrictCmds=false grep $pattern` would restore the previous
behavior of falling back to the cache for non-present entries, which
is not true.

In particular, I would like to emphasize that the use for
`sparse.restrictCmds=false` in the working tree case, is for
situations like the one you described in [1]:

* uses sparse-checkout to remove a bunch of files/directories they
don't care about
* creates a new file that happens to have the same name as an
(unfortunately) generically worded filename that exists in the index
(but is marked SKIP_WORKTREE and had previously been removed)

In this situation, grep would ignore the said file by default, but
search it with `sparse.restrictCmds=false`.

So what do you think of the following:

sparse.restrictCmds::
See base definition in linkgit:git-config[1]. grep honors
sparse.restrictCmds by limiting searches to the sparsity paths in
three cases: when searching the working tree, when searching the index
with --cached, and when searching a specified commit. Note: when this
option is set to true (default), the working tree search will ignore
paths that are present despite not matching the sparsity patterns.
This can happen, for example, if you create a new file in a path that
was previously removed by git-sparse-checkout. Or if you don't
deinitialize a submodule that is excluded by the sparsity patterns
(thus remaining in the working copy, anyway).

[1]: https://lore.kernel.org/git/CABPp-BE+BL3Nq=Co=-kNB_wr=6gqX8zcGwa0ega_pGBpk6xYsg@xxxxxxxxxxxxxx/



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux