(This issue was AI generated but I have reviewed it, understood it, and I'm accountable for its content.)
Version: gh-stack v0.1.0.
Setup: trunk main; stack A ← B (gh stack init A B); A has commit A1 modifying f.txt, B has commit B1 adding g.txt.
Repro: amend A1 on A (change f.txt, keep the message), then gh stack rebase.
Expected: B is rebased by replaying only B1 onto the amended A — B's recorded base (old A tip) is still an ancestor of B and delimits exactly B's own commits.
Actual: the recorded base is discarded (apparently because it is no longer in A's history), the boundary falls back to merge-base(A, B) — below the amendment — and the old A1 is replayed onto the amended A: a bogus conflict in f.txt.
Worse variant (silent corruption): if the amendment only removes part of A1 (e.g. A1 touched f.txt + extra.txt, and the amend drops the extra.txt change), the old A1 replays cleanly: B ends up with a duplicated commit and the removed extra.txt resurrected — reported as success.
Suggested fix: accept a recorded base as the --onto boundary whenever it is an ancestor of the branch being rebased; membership in the parent's current history should not be required. This matches Graphite's restack semantics and is what makes stacks robust under history editing.
The same failure triggers when the trunk's history is edited (e.g. a commit below the stack is amended via fixup): the whole old trunk segment is replayed into the bottom stack branch.
(This issue was AI generated but I have reviewed it, understood it, and I'm accountable for its content.)
Version: gh-stack v0.1.0.
Setup: trunk
main; stackA ← B(gh stack init A B);Ahas commit A1 modifyingf.txt,Bhas commit B1 addingg.txt.Repro: amend A1 on
A(changef.txt, keep the message), thengh stack rebase.Expected:
Bis rebased by replaying only B1 onto the amendedA— B's recorded base (old A tip) is still an ancestor ofBand delimits exactly B's own commits.Actual: the recorded base is discarded (apparently because it is no longer in
A's history), the boundary falls back tomerge-base(A, B)— below the amendment — and the old A1 is replayed onto the amendedA: a bogus conflict inf.txt.Worse variant (silent corruption): if the amendment only removes part of A1 (e.g. A1 touched
f.txt+extra.txt, and the amend drops theextra.txtchange), the old A1 replays cleanly:Bends up with a duplicated commit and the removedextra.txtresurrected — reported as success.Suggested fix: accept a recorded base as the
--ontoboundary whenever it is an ancestor of the branch being rebased; membership in the parent's current history should not be required. This matches Graphite's restack semantics and is what makes stacks robust under history editing.The same failure triggers when the trunk's history is edited (e.g. a commit below the stack is amended via fixup): the whole old trunk segment is replayed into the bottom stack branch.