Skip to content

Commit a92fa17

Browse files
committed
Fix another!
1 parent 7f6fecd commit a92fa17

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

crates/gitbutler-core/src/git/commit_buffer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ impl CommitBuffer {
1010
pub fn new(buffer: &[u8]) -> Result<Self> {
1111
let buffer = str::from_utf8(buffer)?;
1212

13-
dbg!(&buffer);
14-
1513
if let Some((heading, message)) = buffer.split_once("\n\n") {
1614
let heading = heading
1715
.lines()

crates/gitbutler-core/src/virtual_branches/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn get_workspace_head(
6060
let merge_base = repo.merge_base(first_branch.head, merge_parent)?;
6161
workspace_tree = repo.find_commit(merge_base)?.tree()?;
6262
} else {
63-
for branch in dbg!(&applied_branches) {
63+
for branch in &applied_branches {
6464
let branch_tree = repo.find_commit(branch.head)?.tree()?;
6565
let merge_tree = repo.find_commit(target.sha)?.tree()?;
6666
let mut index = repo.merge_trees(&merge_tree, &workspace_tree, &branch_tree, None)?;

crates/gitbutler-core/src/virtual_branches/virtual.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,19 +441,17 @@ pub fn apply_branch(
441441
vb_state.set_branch(branch.clone())?;
442442

443443
ensure_selected_for_changes(&vb_state).context("failed to ensure selected for changes")?;
444-
445444
// checkout the merge index
446445
repo.checkout_index_builder(&mut merge_index)
447446
.force()
448447
.checkout()
449448
.context("failed to checkout index")?;
450449

451-
super::integration::update_gitbutler_integration(&vb_state, project_repository)?;
452-
453450
// Look for and handle the vbranch indicator commit
454451
{
455452
let head_commit = repo.find_commit(branch.head)?;
456-
if let Some(header) = dbg!(head_commit.raw_header()) {
453+
454+
if let Some(header) = head_commit.raw_header() {
457455
if header
458456
.lines()
459457
.any(|line| line.starts_with("gitbutler-vbranch"))
@@ -472,6 +470,9 @@ pub fn apply_branch(
472470
}
473471
}
474472
}
473+
474+
super::integration::update_gitbutler_integration(&vb_state, project_repository)?;
475+
475476
Ok(branch.name)
476477
}
477478

@@ -2572,11 +2573,6 @@ fn is_commit_integrated(
25722573
return Ok(true);
25732574
}
25742575

2575-
// if it's an empty commit we can't base integration status on merge trees.
2576-
if commit.parent_count() == 1 && commit.parent(0)?.tree_id() == commit.tree_id() {
2577-
return Ok(false);
2578-
}
2579-
25802576
// try to merge our tree into the upstream tree
25812577
let mut merge_index = project_repository
25822578
.repo()

crates/gitbutler-core/tests/suite/virtual_branches/move_commit_file.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ async fn move_file_up_overlapping_hunks() {
194194
.find(|b| b.id == branch_id)
195195
.unwrap();
196196
197-
dbg!(&branch.commits);
198197
assert_eq!(branch.commits.len(), 4);
199198
//
200199
}

crates/gitbutler-core/tests/virtual_branches/mod.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ use git2::TreeEntry;
1717
use gitbutler_core::{
1818
git::{self, CommitExt, RepositoryExt},
1919
virtual_branches::{
20-
self, apply_branch,
20+
self,
2121
branch::{BranchCreateRequest, BranchOwnershipClaims, BranchUpdateRequest},
22-
commit, create_virtual_branch, integrate_upstream_commits,
22+
commit, create_virtual_branch, create_virtual_branch_from_branch,
23+
integrate_upstream_commits,
2324
integration::verify_branch,
24-
is_remote_branch_mergeable, list_remote_branches, unapply_ownership, update_branch,
25+
is_remote_branch_mergeable, list_remote_branches, list_virtual_branches, unapply_ownership,
26+
update_branch,
2527
},
2628
};
2729
use pretty_assertions::assert_eq;
@@ -1158,20 +1160,43 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
11581160
},
11591161
)?;
11601162

1161-
virtual_branches::convert_to_real_branch(project_repository, branch2_id, Default::default())?;
1163+
list_virtual_branches(project_repository).unwrap();
1164+
1165+
let real_branch_2 = virtual_branches::convert_to_real_branch(
1166+
project_repository,
1167+
branch2_id,
1168+
Default::default(),
1169+
)?;
1170+
11621171
// check that file2 is back
11631172
let contents = std::fs::read(Path::new(&project.path).join(file_path2))?;
11641173
assert_eq!("file2\n", String::from_utf8(contents)?);
11651174

1166-
virtual_branches::convert_to_real_branch(project_repository, branch3_id, Default::default())?;
1175+
let real_branch_3 = virtual_branches::convert_to_real_branch(
1176+
project_repository,
1177+
branch3_id,
1178+
Default::default(),
1179+
)?;
11671180
// check that file3 is gone
11681181
assert!(!Path::new(&project.path).join(file_path3).exists());
11691182

1170-
apply_branch(project_repository, branch2_id, None)?;
1183+
create_virtual_branch_from_branch(
1184+
project_repository,
1185+
&git::Refname::try_from(&real_branch_2).unwrap(),
1186+
None,
1187+
)
1188+
.unwrap();
1189+
11711190
// check that file2 is gone
11721191
assert!(!Path::new(&project.path).join(file_path2).exists());
11731192

1174-
apply_branch(project_repository, branch3_id, None)?;
1193+
create_virtual_branch_from_branch(
1194+
project_repository,
1195+
&git::Refname::try_from(&real_branch_3).unwrap(),
1196+
None,
1197+
)
1198+
.unwrap();
1199+
11751200
// check that file3 is back
11761201
let contents = std::fs::read(Path::new(&project.path).join(file_path3))?;
11771202
assert_eq!("file3\n", String::from_utf8(contents)?);

0 commit comments

Comments
 (0)