Skip to content

Commit 3f24793

Browse files
authored
Merge pull request #10333 from gitbutlerapp/copilot/fix-507290f8-2d7b-4c0e-9fb6-50f295f653c8
Fix virtual branch identity computation to prevent branches from disappearing
2 parents 02c1b40 + 34753d6 commit 3f24793

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/gitbutler-branch-actions/src/branch.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,15 @@ impl GroupBranch<'_> {
372372
GroupBranch::Virtual(branch) => {
373373
let name_from_source = branch.source_refname.as_ref().and_then(|n| n.branch());
374374
let name_from_upstream = branch.upstream.as_ref().map(|n| n.branch());
375-
let rich_name = branch.name.clone();
376-
let rich_name = normalize_branch_name(&rich_name).ok()?;
377-
let identity = name_from_source.unwrap_or(name_from_upstream.unwrap_or(&rich_name));
378-
Some(identity.into())
375+
376+
// If we have a source refname or upstream, use those directly
377+
if let Some(name) = name_from_source.or(name_from_upstream) {
378+
return Some(name.into());
379+
}
380+
381+
// Only fall back to the normalized rich name if no source/upstream is available
382+
let rich_name = normalize_branch_name(&branch.name).ok()?;
383+
Some(rich_name.as_str().into())
379384
}
380385
}
381386
}

0 commit comments

Comments
 (0)