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

Re: Unexpected cat-file --batch-check output

From
Jeff King <peff@peff.net>
Date
Oct 25, 2021, 19:18 UTC
Message-ID
<YXcC8jQbFsaqYN2M@coredump.intra.peff.net>
In-Reply-To
<CAGyf7-HFGgkXsA-MXBOdiogDid+=F8jmqw0zxwQoUzha-jc1Hw@mail.gmail.com>
On Mon, Oct 25, 2021 at 12:02:38PM -0700, Bryan Turner wrote:
Show 13 quoted lines
> I'm working with some users trying to reconcile an odd mismatch
> observed in some Git output.
> 
> Running an ls-tree for a branch and path, limited to a single pattern
> within, shows this:
> /usr/bin/git ls-tree -z refs/heads/develop:path/to/parent – file
> 100644 blob 4c8d566ed80a1554a059b97f7cd533a55bbd2ea8    file
> 
> If we then run cat-file --batch-check, though, we see this:
> echo 'refs/heads/develop
> refs/heads/develop:path/to/parent/file' | /usr/bin/git cat-file --batch-check
> 28a05ce2e3079afcb32e4f1777b42971d7933a91 commit 259
> cc10f4b278086325aab2f95df97c807c7c6cd75e commit 330
That's definitely odd. Some things I'd try:
  - do other versions of cat-file behave differently (i.e., is it a
    regression)?
  - what does "git rev-parse refs/heads/develop:path/to/parent/file"
    say? If it comes up with 4c8d566ed80, then the problem is cat-file
    specific. If not, then it's a problem in the name resolution
    routines.
  - likewise, what does "git cat-file -t cc10f4b27808" say? I'd expect
    it to really be a commit (a bug in batch-check's formatting routines
    could show the wrong object, but I'd expect the oid to at least
    match what ls-tree showed).
  - Is there anything odd about the tree? E.g., duplicate entries, out
    of order entries, etc? Examining "ls-tree" output might help, but
    "git fsck" should also note any irregularities.

After that, I'd probably start running "cat-file --batch-check" through a debugger. I know you said you don't have access to the repository, but perhaps whoever does might be willing to run it through "fast-export --anonymize" and see if the bug persists?

-Peff
Previous: Bryan TurnerNext: Bryan Turner
Message 2 of 6 in “Unexpected cat-file --batch-check output”
  1. Bryan TurnerOct 25, 2021
  2. Jeff KingOct 25, 2021
  3. Bryan TurnerOct 25, 2021
  4. Bryan TurnerOct 26, 2021
  5. Jeff KingOct 27, 2021
  6. Johannes SixtOct 27, 2021

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.