Skip to content

Commit

Permalink
temp(on disk fixup): Try to fix abandoned branches
Browse files Browse the repository at this point in the history
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 ...`
  • Loading branch information
claytonrcarter committed Aug 11, 2023
1 parent b74562d commit 2343055
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions git-branchless-lib/src/core/rewrite/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ impl ToString for RebaseCommand {
.iter()
.map(|oid| format!("fixup {oid}"))
.collect::<Vec<String>>();
let mut cleanups = vec![];

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

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

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

picks
.iter()
Expand Down

0 comments on commit 2343055

Please sign in to comment.