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

Re: [RFC PATCH 1/3] list-objects: support for skipping tree traversal

From
Matthew DeVore <matvore@google.com>
Date
Oct 18, 2018, 00:25 UTC
Message-ID
<CAMfpvhK=CgamUGTa9b308WRA1Dw4w0Qbt8a4LiKVLFaW6nMwBQ@mail.gmail.com>
In-Reply-To
<xmqqa7ng86i6.fsf@gitster-ct.c.googlers.com>
On Sun, Oct 14, 2018 at 4:15 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>
> This step looks more like "ow, we could have done the tree:0 support
> that is in 'next' better" than a part of "here is a series to do
> tree:N for non zero value of N".
>
> If that is the case, I'd prefer to see this step polished enough
> before [2-3/3] of this RFC is worked on, so that we can merge the
> tree:0 (but not yet tree:N) support that is solid down to 'master'
> soonish.

That's fair. So I will prioritize this patch above the rest of the patchset and send it separately in the future.

> OK, so "not collecting omits" is synonymous to "N==0, we aren't
> doing tree at any level", and at this point in the series before the
> support for N>0 is introduced, we'd always take this "else" clause
> because tree:0 is the only thing we support?

Actually "not collecting omits" and depth==0 are orthogonal concepts. "Collect omits" is the logic needed to implement the --filter-print-omitted flag on git rev-list. You can do this when depth==0 (it will actually print all the trees and blobs recursively). "Collect omits" is tested *with* tree:0 in test t6112 in the test labeled 'verify tree:0 includes trees in "filtered" output'

IOW, both branches here are important even in this patch. If we are collecting omits, then we can't skip the tree because omits collecting is recursive. Otherwise, we *can* skip the tree.

But maybe printing omits should not be recursive? The decision was never discussed. The code to not be recursive is simpler, because we don't need this if/else. Recursiveness is counter-intuitive since we would "skip" a tree and at the same time print its contents.

Show 5 quoted lines
>
> Style: our modern style is to use {} around the body which is a
> single statement on the else clause when the body of the
> corresponding if clause needs {} around (and vice versa), so
>

Fixed, and I didn't realize I was supposed to be hugging "else" with the curly braces. What you say is what CodingGuidelines says to do. Thanks for pointing that out.

Show 5 quoted lines
>
> Even when failed_parse==true, i.e. we found that the tree object's
> data cannot be understood, if we have skip-tree bit set, that means
> we do not care---we won't be descending into its children anyway.
>
Yes.
Show 15 quoted lines
> > +# Make sure tree:0 does not iterate through any trees.
> > +
> > +test_expect_success 'filter a GIANT tree through tree:0' '
> > +     GIT_TRACE=1 git -C r3 rev-list \
> > +             --objects --filter=tree:0 HEAD 2>filter_trace &&
> > +     grep "Skipping contents of tree [.][.][.]" filter_trace >actual &&
>
> Here you are not jus tmaking sure SKIP_TREE bit is set for some
> tree, but it is set when base->buf is an empty string (i.e. the top
> level tree)?  Which makes sense, and the next text makes sure that
> between the two commits, the number of total "top level" trees is 2,
> but I wonder if it is more direct to also make sure that the code is
> not even seeing or skipping any tree inside these top level trees
> (i.e. the same message but for ""!=base->buf should never appear in
> the trace).
Makes sense. I added another check in this test for other "Skipping" messages.
Thank you for reviewing.
Previous: Junio C HamanoNext: Matthew DeVore
Message 4 of 14 in “support for filtering trees and blobs based on depth”
  1. 0/3 support for filtering trees and blobs based on depthMatthew DeVore, Oct 11, 2018
  2. 1/3 list-objects: support for skipping tree traversalMatthew DeVore, Oct 11, 2018
  3. Junio C HamanoOct 14, 2018
  4. Matthew DeVoreOct 18, 2018
  5. 2/3 Documentation/git-rev-list: s/<commit>/<object>/Matthew DeVore, Oct 11, 2018
  6. Junio C HamanoOct 14, 2018
  7. Matthew DeVoreOct 20, 2018
  8. Junio C HamanoOct 22, 2018
  9. Matthew DeVoreDec 7, 2018
  10. Junio C HamanoDec 8, 2018
  11. 3/3 list-objects-filter: teach tree:# how to handle >0Matthew DeVore, Oct 11, 2018
  12. Junio C HamanoOct 15, 2018
  13. Matthew DeVoreNov 8, 2018
  14. Matthew DeVoreDec 10, 2018

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.