Skip to content

Commit 9eafe29

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 d682449 commit 9eafe29

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
@@ -154,7 +154,6 @@ impl ToString for RebaseCommand {
154154
.iter()
155155
.map(|oid| format!("fixup {oid}"))
156156
.collect::<Vec<String>>();
157-
let mut cleanups = vec![];
158157

159158
// Since 0ca8681, the intermediate commits created as each
160159
// fixup is applied are left behind in the smartlog. This
@@ -177,14 +176,14 @@ impl ToString for RebaseCommand {
177176
// We have to add some additional steps to make sure the
178177
// smartlog and commit metadata are left as the user
179178
// expects.
180-
if pick_oid != original_commit_oid {
179+
let cleanups = if pick_oid != original_commit_oid {
181180
// See above comment related to 0ca8681
182181
picks.insert(
183182
1,
184183
"exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string()
185184
);
186185

187-
cleanups = vec![
186+
vec![
188187
// Hide the final squashed commit
189188
"exec git branchless hook-skip-upstream-applied-commit $(git rev-parse HEAD)".to_string(),
190189

@@ -196,8 +195,14 @@ impl ToString for RebaseCommand {
196195
// Finally, register the new final commit as the
197196
// rewritten version of original_commit_oid
198197
format!("exec git branchless hook-skip-upstream-applied-commit {original_commit_oid} $(git rev-parse HEAD)")
199-
];
200-
}
198+
]
199+
} else {
200+
vec![
201+
// HACK force move branches that used to point at original_commit_oid to new HEAD
202+
// FIXME Yuck! The for loop works by word, not by line; will not work for branches w/ spaces ... is that a thing?
203+
format!("exec for BRANCH in $(git branch --points-at {original_commit_oid}); do git branch --force \"$BRANCH\" HEAD; done"),
204+
]
205+
};
201206

202207
picks
203208
.iter()

0 commit comments

Comments
 (0)