Skip to content

Commit 0a5a679

Browse files
temp(on disk fixup): Try to fix abandoned branches
This is just a hack to fix one specific test failure. I haven't dug into it, but I assume there is something more interesting happening than the one case I'm patching with `branch -f ...`
1 parent ed5ef73 commit 0a5a679

File tree

1 file changed

+10
-5
lines changed
  • git-branchless-lib/src/core/rewrite

1 file changed

+10
-5
lines changed

git-branchless-lib/src/core/rewrite/plan.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ impl RebaseCommand {
144144
.iter()
145145
.map(|oid| format!("fixup {oid}"))
146146
.collect::<Vec<String>>();
147-
let mut cleanups = vec![];
148147

149148
// Since 0ca8681, the intermediate commits created as each
150149
// fixup is applied are left behind in the smartlog. This
@@ -167,14 +166,14 @@ impl RebaseCommand {
167166
// We have to add some additional steps to make sure the
168167
// smartlog and commit metadata are left as the user
169168
// expects.
170-
if pick_oid != original_commit_oid {
169+
let cleanups = if pick_oid != original_commit_oid {
171170
// See above comment related to 0ca8681
172171
picks.insert(
173172
1,
174173
"exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string()
175174
);
176175

177-
cleanups = vec![
176+
vec![
178177
// Hide the final squashed commit
179178
"exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string(),
180179

@@ -186,8 +185,14 @@ impl RebaseCommand {
186185
// Finally, register the new final commit as the
187186
// rewritten version of original_commit_oid
188187
format!("exec git branchless hook-skip-upstream-applied-commit {original_commit_oid} $(git rev-parse HEAD)")
189-
];
190-
}
188+
]
189+
} else {
190+
vec![
191+
// HACK force move branches that used to point at original_commit_oid to new HEAD
192+
// FIXME Yuck! The for loop works by word, not by line; will not work for branches w/ spaces ... is that a thing?
193+
format!("exec for BRANCH in $(git branch --points-at {original_commit_oid}); do git branch --force \"$BRANCH\" HEAD; done"),
194+
]
195+
};
191196

192197
picks
193198
.iter()

0 commit comments

Comments
 (0)