Skip to content

Remove reference creation for namespaced branches #8320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions crates/gitbutler-branch-actions/src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,40 +246,42 @@ pub fn update_workspace_commit(
index.read_tree(&workspace_tree)?;
index.write()?;

// finally, update the refs/gitbutler/ heads to the states of the current virtual branches
for branch in &virtual_branches {
let wip_tree = repo.find_tree(branch.tree(ctx)?)?;
let mut branch_head = repo.find_commit(branch.head_oid(&gix_repo)?.to_git2())?;
let head_tree = branch_head.tree()?;

// create a wip commit if there is wip
if head_tree.id() != wip_tree.id() {
let mut message = "GitButler WIP Commit".to_string();
message.push_str("\n\n");
message.push_str("This is a WIP commit for the virtual branch '");
message.push_str(branch.name.as_str());
message.push_str("'\n\n");
message.push_str("This commit is used to store the state of the virtual branch\n");
message.push_str("while you are working on it. It is not meant to be used for\n");
message.push_str("anything else.\n\n");
let branch_head_oid = repo.commit(
None,
&committer,
&committer,
&message,
&wip_tree,
&[&branch_head],
// None,
if !ctx.app_settings().feature_flags.v3 {
// finally, update the refs/gitbutler/ heads to the states of the current virtual branches
for branch in &virtual_branches {
let wip_tree = repo.find_tree(branch.tree(ctx)?)?;
let mut branch_head = repo.find_commit(branch.head_oid(&gix_repo)?.to_git2())?;
let head_tree = branch_head.tree()?;

// create a wip commit if there is wip
if head_tree.id() != wip_tree.id() {
let mut message = "GitButler WIP Commit".to_string();
message.push_str("\n\n");
message.push_str("This is a WIP commit for the virtual branch '");
message.push_str(branch.name.as_str());
message.push_str("'\n\n");
message.push_str("This commit is used to store the state of the virtual branch\n");
message.push_str("while you are working on it. It is not meant to be used for\n");
message.push_str("anything else.\n\n");
let branch_head_oid = repo.commit(
None,
&committer,
&committer,
&message,
&wip_tree,
&[&branch_head],
// None,
)?;
branch_head = repo.find_commit(branch_head_oid)?;
}

repo.reference(
&branch.refname()?.to_string(),
branch_head.id(),
true,
"update virtual branch",
)?;
branch_head = repo.find_commit(branch_head_oid)?;
}

repo.reference(
&branch.refname()?.to_string(),
branch_head.id(),
true,
"update virtual branch",
)?;
}

Ok(final_commit)
Expand Down
Loading