Skip to content

Implement ghstack pull#354

Open
ezyang wants to merge 1 commit into
mainfrom
gh/ezyang/67/head
Open

Implement ghstack pull#354
ezyang wants to merge 1 commit into
mainfrom
gh/ezyang/67/head

Conversation

@ezyang
Copy link
Copy Markdown
Owner

@ezyang ezyang commented May 13, 2026

No description provided.

Implement `ghstack pull` as a new subcommand that pulls remote updates
for a ghstack PR into the local working tree. The command resolves the
PR from HEAD's commit message or an explicit PR argument, fetches the
remote head/orig refs, and merges remote changes with local changes.

Key behaviors:
- Fast-forward: if the local commit is an ancestor of the remote orig,
  simply check out the remote orig directly.
- Clean merge: use `git merge-tree --write-tree` to produce a merged
  tree without touching the worktree, then create a new orig commit
  with the merged tree and updated ghstack-source-id.
- Conflict: fall back to `git merge-recursive` to materialize conflicts
  in the worktree, save state to `.git/GHSTACK_PULL`, and instruct the
  user to resolve and run `ghstack pull --continue`.
- Continue: `--continue` validates that conflicts are resolved and all
  changes are staged, then writes the merged tree and checks out the
  result.

The merge strategy works by finding the remote head commit whose tree
matches the local ghstack-source-id (establishing the common ancestor),
creating an imputed head commit from the local tree, and merging that
against the remote head.

Includes three test scenarios: basic non-conflicting pull, conflicting
pull with manual resolution via --continue, and explicit PR argument
with fast-forward.

[ghstack-poisoned]
@ezyang
Copy link
Copy Markdown
Owner Author

ezyang commented May 13, 2026

Stack from ghstack (oldest at bottom):

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