Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dscho
Copy link
Contributor

@dscho dscho commented Aug 3, 2025

When trying to import Git for Windows' commit history into jj, I noticed that I couldn't:

Error: Failed to import refs from underlying Git repo
Caused by:
1: Ancestor of Git ref main@origin is missing
2: Error when reading object 5f549aa2f78314ac37bbd436c8f80aea4c752e07 of type commit
3: object parsing failed
Hint: Is this Git repository a partial clone (cloned with the --filter argument)?
jj currently does not support partial clones. To use jj with this repository,
try re-cloning with the full repository contents.

The reason is of course git/git@5f549aa, which has incorrect commit headers:

tree db079155794727ac821adfba2eb68b330cc0c120
parent 33a11a20eb7610771268e34211509cbbdee76b1e
author Junio C Hamano <[email protected]> 1319256362 -0700
committer Junio C Hamano <[email protected]> 1319259176 -0700
gpgsig -----BEGIN PGP SIGNATURE-----
gpgsig Version: GnuPG v1.4.10 (GNU/Linux)
gpgsig 
gpgsig iQIcBAABAgAGBQJOokwoAAoJELC16IaWr+bL0WoP/2QKYkWpEyXF608m2L/cB9Qx
gpgsig /N0oBjyL1guIjPX9B3Wxq80dnLLEPnpnO39aiQIXFoJS0L6KEurqK6uDPHy3/ULa
gpgsig QsAug2HeCLsDnIFbzFSpSIMv/bP/72FDb/idMBT99xTcQj5UJEUgj7AAtx0vnKvQ
gpgsig pQIXtPu5GBUdhl3SiGgiJFRyp4r5EgV5I40GBwx/ty9cPEIN7ukJ3CR9+KC8eIGx
gpgsig Az7qngi3dhTn7g+3Z8XX5OYFDMSt9xn1gxqWXOMNlG0mxCvpFe59kwciugp26KVp
gpgsig n+yJ0UOdoxyZX8pdqXQjvklmoo7e55aaxtbHe7KSD56ebL7h7vHhkGWORU1dOp+h
gpgsig Iv5dQItkKSR8afB7FmRjo8+B/2g0wZDKRTGhzm7d1gooO5gpXvuvm4GRl5Io+IEj
gpgsig c7Li3EYmXADWUZWJtbDKDgKGKIOmWv72Qrz52iaESrhZ909HiXfn/jhHBuDRmLtQ
gpgsig /4v3T4O25uhdZ4p/PjHQn/ZroCmDyMwmnrtw/tt5fSNrl4qGcYg8Jj/1ynfF1AtS
gpgsig dM2LR65sOwXzSsqAbQjyRFYMLSWhHd/h8BcpZHDXmNBkZJVPm4zvD3ZVaAo6rtZD
gpgsig WJ9YXWXtPhuf09OgYBzcBlamTrk9ByH+NCIdrFkqfhNF1YI5dArSZytIXJhpPI1e
gpgsig TrmQAZf0BiI5J6PYN0AI
gpgsig =Qg/+
gpgsig -----END PGP SIGNATURE-----

pretty: %G[?GS] placeholders

Add new placeholders related to the GPG signature on signed commits.

 - %GG to show the raw verification message from GPG;
 - %G? to show either "G" for Good, "B" for Bad;
 - %GS to show the name of the signer.

Signed-off-by: Junio C Hamano <[email protected]>

Note the multiple gpgsig header lines? In particular the one that has no value? That's the problem. Unfortunately, the error message from the parser was not helpful (it was empty), but in any case, the fix is relatively obvious, I think.

While at it, I looked at similar take_till() calls and think I found similar issues in some, which are fixed in a separate commit.

@dscho dscho marked this pull request as draft August 3, 2025 12:18
dscho added 2 commits August 3, 2025 12:33
The C Git source code repository itself contains a commit with bogus
`gpgsig` lines: 5f549aa2f783 (pretty: %G[?GS] placeholders, 2011-10-21).
Basically, this commit's headers contain a GPG signature that _should_
have been a multi-line header, but instead every line of that signature
was added individually as a `gpgsig` header. Crucially, this includes a
header line that starts with `gpgsig` followed by a space and that's
already the end of the line.

Gitoxide's commit header parser was not prepared for that. Even worse:
the error message in that instance was simply empty.

Let's make the parser more robust by accepting such commit headers, and
add a test to verify that the commit in question _can_ be parsed by
Gitoxide.

Signed-off-by: Johannes Schindelin <[email protected]>
I just fixed a problem where a `gpgsig ` header line in a historical
commit in the git.git repository itself was mistakenly causing a parse
error. The culprit was, of course, that the header value is empty, and
the existing code expected the value _not_ to be empty.

Handle similar issues in other locations, too.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the fix-parsing-of-legacy-git.git-commit branch from 3afe006 to a0660fe Compare August 3, 2025 12:33
- make the test more specific to what it's testing
- fix a bug in the way multi-line headers are written so the object can be serialised.
@dscho dscho marked this pull request as ready for review August 3, 2025 13:21
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great catch, thanks a lot!

I found another related bug and fixed that, too. Two flies one stone if you will. Many more flies if the additional leniency really kicks in.

There should be a new patch release shortly.

@Byron Byron enabled auto-merge August 3, 2025 13:24
@Byron Byron merged commit ef73c6b into GitoxideLabs:main Aug 3, 2025
23 checks passed
@dscho dscho deleted the fix-parsing-of-legacy-git.git-commit branch August 3, 2025 13:49
@dscho
Copy link
Contributor Author

dscho commented Aug 3, 2025

Nice, thank you @Byron!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants