* Bug Report: git show unnecessarily requires parent tree
@ 2025-05-23 6:15 Bell, Bob (ISG)
2025-05-23 17:17 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Bell, Bob (ISG) @ 2025-05-23 6:15 UTC (permalink / raw)
To: git@vger.kernel.org
What did you do before the bug happened? (Steps to reproduce your issue)
Tree-less git partial clone: git clone --filter=tree:0 https://...
Remove the promisor to prevent retrieving more objects: git config --local --unset remote.origin.promisor
Git show of a fetched commit with limited metadata fields requested: git show --no-patch --format=%ae abc123
What did you expect to happen? (Expected behavior)
I expect to get the metadata I requested from the commit, since it is available in the retrieved commit object
What happened instead? (Actual behavior)
I get an error attempting to read the tree for the parent of the commit specified:
fatal: unable to read tree (abcdef1234567890)
What's different between what you expected and what actually happened?
I expected the command to output the requested metadata, since there is no need to read the parent commit, much less the parent's tree object, in order to provide the required data.
Anything else you want to add:
Note that the data is fully accessible without error using git cat-file or git log
e.g., git log -n 1 --format=%ae abc123
Please review the rest of the bug report below.
You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.47.2
cpu: x86_64
no commit associated with this build
--
Bob Bell
Distinguished Member of Technical Staff
Dell | ISG TechOps
Robert.Bell@Dell.com
Internal Use - Confidential
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug Report: git show unnecessarily requires parent tree
2025-05-23 6:15 Bug Report: git show unnecessarily requires parent tree Bell, Bob (ISG)
@ 2025-05-23 17:17 ` Junio C Hamano
2025-05-23 19:36 ` Bell, Bob (ISG)
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2025-05-23 17:17 UTC (permalink / raw)
To: Bell, Bob (ISG), Jeff King; +Cc: git
"Bell, Bob (ISG)" <Robert.Bell@dell.com> writes:
> What did you do before the bug happened? (Steps to reproduce your issue)
> Tree-less git partial clone: git clone --filter=tree:0 https://...
> Remove the promisor to prevent retrieving more objects: git config --local --unset remote.origin.promisor
At this point, your repository is officially corrupt, but it is a
very effective way to demonstrate the underlying issue that exists
even if your repository weren't corrupt.
I do agree with you that "git show -s", without any other options
like --diff-filter that affects the commit selection [*], should not
have to look into its tree. Unlike "git log -p", it should not have
to see the tree of the commit is the same or different from the tree
of the parent commit in order to decide if the commit should be
shown.
The fact that it gave an error "attempting to read the tree" is your
own making by corrupting your repository ;-), but it is done as an
easy way to demonstrate the underlying issue, which is that it is
suboptimal for it to try to access the tree of the commit in a case
where it should not have to.
Is this essentially the same issue as these?
https://lore.kernel.org/git/YqEyh5opAaJxph2+@coredump.intra.peff.net/
https://lore.kernel.org/git/20250504082715.GA6257@coredump.intra.peff.net/
[Footnote]
* "git show -s --diff-filter=D" on a commit that does not delete
any paths is silent. "-s" merely says "do not show the output
from the diff machinery". The same for pathspec, to wit:
$ git commit --allow-empty -m empty
$ git show -s .
It asks "if there are any changes to paths that match the
pathspec, show the commit but do not show the diff output".
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Bug Report: git show unnecessarily requires parent tree
2025-05-23 17:17 ` Junio C Hamano
@ 2025-05-23 19:36 ` Bell, Bob (ISG)
0 siblings, 0 replies; 3+ messages in thread
From: Bell, Bob (ISG) @ 2025-05-23 19:36 UTC (permalink / raw)
To: Junio C Hamano, Jeff King; +Cc: git@vger.kernel.org
> I do agree with you that "git show -s", without any other options like --diff-
> filter that affects the commit selection [*], should not have to look into its tree.
> Unlike "git log -p", it should not have to see the tree of the commit is the same
> or different from the tree of the parent commit in order to decide if the
> commit should be shown.
And indeed, as noted, "git log" *without* "-p" functions fine, whereas "git
show -s" reads the tree object in regardless. I suppose maybe that has
something to do with their respective "default states". I believe my current
workaround will involve using "git log" (or just downloading the trees and not
the blobs with "blob:none" instead).
> The fact that it gave an error "attempting to read the tree" is your own making
> by corrupting your repository ;-), but it is done as an easy way to demonstrate
> the underlying issue, which is that it is suboptimal for it to try to access the
> tree of the commit in a case where it should not have to.
Thanks. I could have indeed kept the promisor and positioned it as "git
fetches objects it doesn't really need to fetch", but I thought displaying an
error was clearer. Thanks for seeing through it to the core issue. Indeed,
what I'm really wanting to do is optimize what is retrieved as much as
possible, so that I can operate at scale with minimal overhead (both locally in
execution time, and load generated on our internal server). This is really
just part of the path getting there, and it seemed worth reporting for
consideration. I'll push past it and lurk in the background in case you decide
to implement any changes. :-)
[ Apologies for any rough issues in email formatting -- I'm utilizing Outlook
from a corporate setting that isn't regularly configured for mailing lists, and
doing the best with what I have right now ]
-- Bob
Internal Use - Confidential
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-23 21:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 6:15 Bug Report: git show unnecessarily requires parent tree Bell, Bob (ISG)
2025-05-23 17:17 ` Junio C Hamano
2025-05-23 19:36 ` Bell, Bob (ISG)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox