git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-grep in sparse checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 2, 2019, 06:33 UTC
Message-ID
<xmqqy2y3ejwe.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CABPp-BGuFhDwWZBRaD3nA8ui46wor-4=Ha1G1oApsfF8KNpfGQ@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
> * other commands (archive, bisect, clean?, gitk, shortlog, blame,
> fsck?, etc.) likely need to pay attention to sparsity patterns as
> well, but there are some special cases:

"git archive" falls into the same class as fast-(im|ex)port; it should ignore the sparse cone by default. I suspect you threw "fsck" as a joke, but I do not think it should pay attention to the sparse cone, either (besides, most of the time in fsck the objects subject to checking do not know all the paths that reach them).

Show 5 quoted lines
> * merge, cherry-pick, and rebase (anything touching the merge
> machinery) will need to expand the size of the non-sparse worktree if
> there are files outside the sparsity patterns with conflicts.  (Though
> merge should do a better job of not expanding the non-sparse worktree
> when files can cleanly be resolved.)

I think the important point is what is done to the result of operation. Result of these operations that create new commits are meant to be consumed by other people, who may not share your definition of sparse cone. And such a command (i.e. those whose results are consumed by others who may have different sparse cone) must be full-tree by default.

> * fast-export and format-patch are not about viewing history but about
> exporting it, and limiting to sparsity patterns would result in the
> creation of an incompatible history.
I agree with the conclusion; see above.
> * New worktrees, by default, should copy the sparsity-patterns of the
> worktree they were created from (much like a new shell inherits the
> current working directory of it's parent process)
Sorry, but I do not share this view at all.

In my mental model, "worktree new" is to attach a brand-new worktree to a bare repository that underlies the existing worktree I happen to be in, and that existing worktree that I happen to type "worktree new" in is no more or no less special than other worktrees.

The above isn't to say that I'd veto your "a new worktree inherits traits from an existing worktree that 'git worktree add' was invoked in" idea. I am just saying that I have a problem with that mode of operation and mental model being the default.

Previous: Elijah NewrenNext: Elijah Newren
Message 4 of 9 in “git-grep in sparse checkout”
  1. Matheus Tavares BernardinoOct 1, 2019
  2. Bert WesargOct 1, 2019
  3. Elijah NewrenOct 1, 2019
  4. Junio C HamanoOct 2, 2019
  5. Elijah NewrenOct 2, 2019
  6. Derrick StoleeOct 1, 2019
  7. Matheus Tavares BernardinoOct 2, 2019
  8. Junio C HamanoOct 2, 2019
  9. Derrick StoleeOct 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.