Repository navigation
fix(git): push auth via git CLI, --branch flag, and round-trip dedup - #146
Merged
Merged
Conversation
The libgit2 push path failed for anyone whose SSH setup isn't "keys in an agent": its credential callback only called ssh_key_from_agent(). Keys referenced via Host/IdentityFile in ~/.ssh/config (a common setup, e.g. IdentityFile ~/.ssh_keys/github with an empty agent) made every push fail with "Failed getting response; class=Ssh(23)" — after a slow retry loop that looked like a hang. push_to_remote now runs 'git push <remote> <refspec>' via the git CLI with inherited stdio, so authentication behaves exactly like the user's own git push: OpenSSH client config, ssh-agents, askpass prompts, and HTTPS credential helpers all work. A comment warns against reverting to libgit2's transport. Also fixes the stranded-commit trap: when a push failed after the commit was created, the next run reported "Nothing to commit" and exited, leaving the commit unpushed. The nothing-to-commit path now checks upstream tracking via graph_ahead_behind and pushes any unpushed commits instead. Tested end-to-end against a live GitHub repo with the exact failing setup: stranded-commit recovery push, then a full record -> push cycle with correct Atomic-View/Atomic-State/Atomic-Changes trailers.
atomic git push always pushed the checked-out branch to its same-named remote branch. Add --branch/-b to override the target: the commit is still created on the current branch, but the refspec becomes HEAD:refs/heads/<target>, so the current view's state can be pushed to a PR branch without switching local branches. The nothing-to-commit path is target-aware: with an explicit --branch it compares against refs/remotes/<remote>/<target>, and pushes the current state even when there is nothing new (creating the remote branch); without --branch it keeps the upstream-tracking comparison. Also fixes the success message naming the Atomic view instead of the actual git branch the push landed on.
The push -> pull -> import round trip duplicated history: a commit
created by 'atomic git push' came back into the view as a new change
on the next 'atomic git import --incremental', duplicating the changes
it was built from (observed live: 5 pushed commits reimported as 5
duplicate changes).
The commit already carries proof that it's ours: the Atomic-View and
Atomic-State trailers written at push time. Atomic-State is the Merkle
of the view's change sequence, so if it exists in the view's STATES
table, every change in that commit is present by definition.
On incremental import, parse the trailers (strictly: they must form
the message's final paragraph, so GitHub squash messages that quote
them mid-body don't match) and skip the commit when the trailer's view
is the import target and its state is known. STATES is append-only,
so this also dedupes commits pushed before this fix. Full imports and
cross-view cases (pushed from dev, imported on main) are unaffected.
Also fixes squash/merge classification never firing: classify_commit
received only the commit subject, but trailers live in the body —
ImportedCommitInfo now carries the full message, so ReviewGate tags
(pr-N / merge-sha) are actually created.
E2E verified: record -> push -> import --incremental writes 0 changes
("Skipped 1 commit created by atomic git push"); plain git commits
import normally; a squash-shaped commit imports + gets its pr-100 tag.
TagRecord.metadata is Option<serde_json::Value>, which postcard cannot deserialize (non-self-describing format: Value requires deserialize_any). Tags with metadata — produced by the git-import squash classifier — wrote successfully but every read failed with "failed to deserialize TagRecord", breaking 'atomic tag list'. Store the field as JSON text via a serde adapter. Records with no metadata (the pre-metadata format) decode unchanged; metadata-carrying records were previously unreadable, so nothing readable is broken by the format change.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three issues in the Git shadow system, all verified live:
atomic git pushfailed to authenticate for anyone whose SSH setup isn't "keys in an agent". The libgit2 credential callback only calledssh_key_from_agent()— keys referenced viaHost/IdentityFilein~/.ssh/configwere never consulted, so pushes failed withFailed getting response; class=Ssh (23)after a hang-like retry loop, while plaingit pushworked fine. After a failed push, the local commit was stranded: the next run said "Nothing to commit" and exited.atomic git pushcame back into the view as a brand-new change on the nextatomic git import --incremental(observed: 5 pushed commits reimported as 5 duplicates). Squash/merge classification also never fired — it parsed only the commit subject, but trailers live in the body — so noReviewGatetags were created either.TagRecord.metadataisOption<serde_json::Value>, which postcard can't deserialize — every read of a classifier-created tag failed, breakingatomic tag list.Fixes
Push auth (
git/push.rs) —push_to_remotedelegates the network operation to thegitCLI with inherited stdio, so auth behaves exactly like the user's owngit push(ssh config, agents, askpass, HTTPS credential helpers). The nothing-to-commit path now checks upstream tracking and pushes stranded commits. New--branch/-bflag pushes the current view's state to a different remote branch (HEAD:refs/heads/<target>); commit is still created on the current branch.Round-trip dedup (
git/import.rs,git/parallel.rs) — on incremental import, parseAtomic-View/Atomic-Statetrailers (strictly: final paragraph only, so GitHub squash messages quoting them mid-body don't match) and skip the commit when its view is the import target and its state exists in the view's append-onlySTATEStable — the Merkle proves every change it carries is already present. Retroactive: dedupes commits pushed before this fix. Cross-view (pushed fromdev, imported onmain) and full imports unaffected. Classification now receives the full commit message, so squash merges actually get theirpr-Ntags.Tag serialization (
pristine/traits/tag.rs) —metadatais stored as JSON text via a serde adapter; metadata-free records decode unchanged.Verified end-to-end (live GitHub repo)
record→git push→git import --incremental→ 0 changes written, "Skipped 1 commit created byatomic git push(state already in view)" ✓pr-100tag created with full metadata;tag list/tag showrender it ✓--branch pr-democreates a remote branch,mainuntouched ✓