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

Re: [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 3, 2009, 16:25 UTC
Message-ID
<7veiw9aeme.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090402113851.GA12675@atjola.homenet>
Björn Steinbrink <B.Steinbrink@gmx.de> writes:
Show 46 quoted lines
> On 2009.04.01 21:32:05 -0700, Junio C Hamano wrote:
>> I'm planning to queue this.
>> [Improved version of my patch]
>
> Ah, thanks. Got busy with other stuff, and tried to fix another related
> bug in ls-tree which made me forget to send the match_tree_entry fix :-/
>
> That other ls-tree bug is with recursing into subdirectories, because
> match_tree_entry matches even when the base is a subdirectory, but
> ls-tree doesn't actually want that behaviour, I think. For example:
>
> $ git ls-tree --abbrev HEAD git-gui/macosx/AppMain.tcl
> 100644 blob ddbe633	git-gui/macosx/AppMain.tcl
>
> $ git ls-tree --abbrev HEAD  git-gui/
> 100644 blob f96112d	git-gui/.gitattributes
> 100644 blob 6483b21	git-gui/.gitignore
> 100755 blob b3f937e	git-gui/GIT-VERSION-GEN
> 100644 blob 3ad8a21	git-gui/Makefile
> 100755 blob 12e117e	git-gui/git-gui--askpass
> 100755 blob e018e07	git-gui/git-gui.sh
> 040000 tree f723285	git-gui/lib
> 040000 tree 73f3c34	git-gui/macosx
> 040000 tree 11cd1a0	git-gui/po
> 040000 tree 144728d	git-gui/windows
>
> $ git ls-tree --abbrev HEAD git-gui/macosx/AppMain.tcl git-gui/
> 100644 blob f96112d	git-gui/.gitattributes
> 100644 blob 6483b21	git-gui/.gitignore
> 100755 blob b3f937e	git-gui/GIT-VERSION-GEN
> 100644 blob 3ad8a21	git-gui/Makefile
> 100755 blob 12e117e	git-gui/git-gui--askpass
> 100755 blob e018e07	git-gui/git-gui.sh
> 040000 tree f723285	git-gui/lib
> 100644 blob ddbe633	git-gui/macosx/AppMain.tcl
> 100644 blob b3bf15f	git-gui/macosx/Info.plist
> 100644 blob 77d88a7	git-gui/macosx/git-gui.icns
> 040000 tree 11cd1a0	git-gui/po
> 040000 tree 144728d	git-gui/windows
>
> The last ls-tree shows all entries from git-gui/macosx/, beacuse the
> first pattern makes it descend into that tree and all entries are
> matched by the git-gui/ prefix. So the combined ls-tree shows more than
> what the individual calls show. Seems wrong to me, but I'm unsure how to
> tackle that, assuming that match_tree_entry is right in allowing any
> base that's a subdirectory of a specified pathspec.

What might be confusing is how ls-tree, when run without an explicit option -r (ecurse), comes up with candidates to show. With pathspecs, you are instructing it to recurse into subtrees as deep as needed to discover all the paths that can match them, and your first pathspec causes the contents of macosx subtree to be looked at for this reason.

Pathspecs are always OR'ed together, never AND'ed, and your second pathspec git-gui covers them, so I do not think it is a bug.

If we had a glob support in the "leading path components" pathspec matcher used by ls-tree/diff-tree, I would imagine you could do something like;

	ls-tree --recurse-to='*/*/*' $other $pathspec

to say "recurse three levels, but do not use */*/* as a filter to decide what to show; the filters are only $other and $pathspec", iow, using

	(AND "*/*/*" (OR $other $pathspec))

semantics. But I think this kind of complexity falls out of the "useful" category and into a "mental exercise" category.

Previous: Björn SteinbrinkNext: Björn Steinbrink
Message 25 of 28 in “svn clone Checksum mismatch question”
  1. Gilbert LiddellMar 26, 2009
  2. Björn SteinbrinkMar 26, 2009
  3. Gilbert LiddellMar 26, 2009
  4. Sverre RabbelierMar 26, 2009
  5. Gilbert LiddellMar 26, 2009
  6. Johannes SchindelinMar 26, 2009
  7. Anton GyllenbergMar 26, 2009
  8. Anton GyllenbergMar 27, 2009
  9. Eric WongMar 29, 2009
  10. git-svn: fix ls-tree usage with dash-prefixed pathsEric Wong, Mar 29, 2009
  11. Junio C HamanoMar 29, 2009
  12. Eric WongMar 29, 2009
  13. Junio C HamanoMar 30, 2009
  14. Eric WongMar 30, 2009
  15. Junio C HamanoMar 30, 2009
  16. Eric WongMar 30, 2009
  17. Björn SteinbrinkMar 31, 2009
  18. Björn SteinbrinkMar 31, 2009
  19. Björn SteinbrinkMar 31, 2009
  20. tree_entry_interesting: Only recurse when the pathspec is a leading path componentBjörn Steinbrink, Mar 31, 2009
  21. Junio C HamanoApr 2, 2009
  22. match_tree_entry(): a pathspec only matches at directory boundariesJunio C Hamano, Apr 2, 2009
  23. Linus TorvaldsApr 2, 2009
  24. Björn SteinbrinkApr 2, 2009
  25. Junio C HamanoApr 3, 2009
  26. Björn SteinbrinkMar 30, 2009
  27. Anton GyllenbergMar 30, 2009
  28. Peter HarrisMar 26, 2009

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.