`git push --porcelain` prints the source side of each refspec as it was given, so `git push origin <hash>:refs/heads/x` or `HEAD~1:refs/heads/x` reports `<hash>` or `HEAD~1` there. `PushInfo._from_line()` passed it to `Reference.from_path()`, which raised `ValueError`, and `_get_push_info()` dropped the line. A push of only such sources returned an empty list, and a mixed push only the results for the other refspecs. When the source is not a reference, set `local_ref` to `None`, as it already is for deletes, and record the pushed object's hash in a new `local_hash` attribute. This is the shape suggested in gitpython-developers#1624. The hash comes from git's `old..new` summary when there is one, because the push can move a ref the source is relative to, such as `origin/main~1`; only new refs and rejected lines resolve the source. `test_push_revision_sources` pushes a hash, `HEAD~1` and `HEAD` in one call, then force-pushes `self/pushed_ref~1` over the ref it is relative to. It fails without this change under the `cli` and `gix` backends, and passes with it. Agent-Model: claude-opus-5-5
Three gaps in the non-ref source handling, from review:
- `Reference.from_path()` accepts any `refs/` path, so a source such
as `refs/heads/main~1` became a `Head` that does not exist. Sources
with `~`, `^` or `@{`, which `check-ref-format` never allows in a
ref name, are now taken as revisions without trying `from_path()`.
- `rev-parse` prefers a ref over an object ID with the same spelling,
so a branch named like the abbreviated ID in git's summary gave the
wrong `local_hash`. Expand it with `rev-parse --disambiguate`, which
only looks at object IDs.
- A lookup error other than `BadName` escaped the stdout handler and
dropped the push result. Keep the result with `local_hash=None`.
`test_push_revision_sources` covers each case, including a failing
lookup on both paths; each new assertion fails with only its part of
the change reverted, under `cli` and `gix`.
Agent-Model: claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters