Skip to content

fix(git): push auth via git CLI, --branch flag, and round-trip dedup - #146

Merged
geekgonecrazy merged 5 commits into
devfrom
fix/git-push-cli-auth
Aug 4, 2026
Merged

geekgonecrazy merged 5 commits into
devfrom
fix/git-push-cli-auth

Conversation

@geekgonecrazy

@geekgonecrazy geekgonecrazy commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Three issues in the Git shadow system, all verified live:

  1. atomic git push failed to authenticate for anyone whose SSH setup isn't "keys in an agent". The libgit2 credential callback only called ssh_key_from_agent() — keys referenced via Host/IdentityFile in ~/.ssh/config were never consulted, so pushes failed with Failed getting response; class=Ssh (23) after a hang-like retry loop, while plain git push worked fine. After a failed push, the local commit was stranded: the next run said "Nothing to commit" and exited.
  2. The push → pull → import round trip duplicated history. A commit created by atomic git push came back into the view as a brand-new change on the next atomic 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 no ReviewGate tags were created either.
  3. Tags with metadata were unreadable: TagRecord.metadata is Option<serde_json::Value>, which postcard can't deserialize — every read of a classifier-created tag failed, breaking atomic tag list.

Fixes

Push auth (git/push.rs) — push_to_remote delegates the network operation to the git CLI with inherited stdio, so auth behaves exactly like the user's own git push (ssh config, agents, askpass, HTTPS credential helpers). The nothing-to-commit path now checks upstream tracking and pushes stranded commits. New --branch/-b flag 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, parse Atomic-View/Atomic-State trailers (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-only STATES table — the Merkle proves every change it carries is already present. Retroactive: dedupes commits pushed before this fix. Cross-view (pushed from dev, imported on main) and full imports unaffected. Classification now receives the full commit message, so squash merges actually get their pr-N tags.

Tag serialization (pristine/traits/tag.rs) — metadata is 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 by atomic git push (state already in view)" ✓
  • Plain git commit (teammate) still imports normally ✓
  • Squash-shaped commit imports + pr-100 tag created with full metadata; tag list/tag show render it ✓
  • --branch pr-demo creates a remote branch, main untouched ✓
  • Stranded-commit recovery push ✓
  • Tests: 1694 CLI (12 new) + 3361 core (2 new), all green

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.
@geekgonecrazy geekgonecrazy changed the title fix(git-push): delegate push auth to git CLI + add --branch target fix(git): push auth via git CLI, --branch flag, and round-trip dedup Aug 4, 2026
@geekgonecrazy
geekgonecrazy merged commit 913f50f into dev Aug 4, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the fix/git-push-cli-auth branch August 4, 2026 20:52
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.

1 participant