Commit 4f46bd6
Fix branch ancestry check logic in merge script (#15)
* Fix branch ancestry check to use local branches
The is_base_ancestor function was checking remote-tracking branches
(origin/$BASE and origin/$BRANCH), but merge operations performed by
the script haven't been pushed yet. This caused incorrect ancestry
detection for child branches.
The fix leverages control flow analysis: git checkout creates the local
branch from origin if needed, so we checkout first then compare local
refs. This eliminates the need for conditional branch creation and
ensures idempotence even when pushes haven't occurred yet.
Changes:
- Remove ensure_local_branch() and is_base_ancestor() helpers
- Modify has_squash_commit() to use local refs (caller ensures they exist)
- Move git checkout before ancestry checks in update_direct_target()
- Inline merge-base check in update_indirect_target() after checkout
- Add comments explaining the control flow reasoning
* Fix e2e test to checkout feature3 before verifying its content
The test was checking file.txt content after checking out feature4,
so it was reading feature4's content instead of feature3's.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 986f9a7 commit 4f46bd6
2 files changed
Lines changed: 21 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
| 834 | + | |
834 | 835 | | |
835 | 836 | | |
836 | 837 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 36 | | |
44 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
48 | | - | |
49 | | - | |
| 44 | + | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| |||
64 | 60 | | |
65 | 61 | | |
66 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
134 | | - | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
| |||
0 commit comments