Skip to content

Commit ef6b09b

Browse files
committed
Fix another!
1 parent 2e17851 commit ef6b09b

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
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
@@ -440,19 +440,17 @@ pub fn apply_branch(
440440
vb_state.set_branch(branch.clone())?;
441441

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

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

@@ -2588,11 +2589,6 @@ fn is_commit_integrated(
25882589
return Ok(true);
25892590
}
25902591

2591-
// if it's an empty commit we can't base integration status on merge trees.
2592-
if commit.parent_count() == 1 && commit.parent(0)?.tree_id() == commit.tree_id() {
2593-
return Ok(false);
2594-
}
2595-
25962592
// try to merge our tree into the upstream tree
25972593
let mut merge_index = project_repository
25982594
.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: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ use std::{
1515
use anyhow::{Context, Result};
1616
use git2::TreeEntry;
1717
use gitbutler_core::{
18-
git::{self, CommitExt, RepositoryExt},
18+
git::{self, diff, CommitExt, RepositoryExt},
1919
virtual_branches::{
20-
self, apply_branch,
20+
self,
2121
branch::{BranchCreateRequest, BranchOwnershipClaims},
22-
commit, create_virtual_branch, integrate_upstream_commits,
23-
integration::verify_branch,
24-
is_remote_branch_mergeable, list_remote_branches, unapply_ownership, update_branch,
22+
commit, create_virtual_branch, create_virtual_branch_from_branch,
23+
integrate_upstream_commits,
24+
integration::{update_gitbutler_integration, verify_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;
@@ -1159,20 +1161,43 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
11591161
},
11601162
)?;
11611163

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

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

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

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

0 commit comments

Comments
 (0)