Skip to content

Commit 567f5b2

Browse files
committed
trying things
1 parent 4d5c6a7 commit 567f5b2

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ but-rebase = { path = "crates/but-rebase" }
7373
but-core = { path = "crates/but-core" }
7474
but-workspace = { path = "crates/but-workspace" }
7575
but-hunk-dependency = { path = "crates/but-hunk-dependency" }
76+
but-debugging = { path = "crates/but-debugging" }
7677

7778
[profile.release]
7879
codegen-units = 1 # Compile crates one after another so the compiler can optimize better

crates/gitbutler-branch-actions/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ toml.workspace = true
4949
pretty_assertions = "1.4"
5050
gitbutler-testsupport.workspace = true
5151
gitbutler-workspace.workspace = true
52+
but-debugging.workspace = true
5253
gix = { workspace = true, features = [] }
5354
glob = "0.3.2"
5455
tempfile.workspace = true

crates/gitbutler-branch-actions/tests/extra/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,8 @@ fn commit_partial_by_hunk() -> Result<()> {
17781778
let list_result = internal::list_virtual_branches(ctx, guard.write_permission())?;
17791779
let branches = list_result.branches;
17801780
let branch = &branches.iter().find(|b| b.id == stack1_id).unwrap();
1781+
1782+
but_debugging::git_log(ctx.repo().path(), but_debugging::LogOptions::default().all(true));
17811783

17821784
assert_eq!(branch.files.len(), 1);
17831785
assert_eq!(branch.files[0].hunks.len(), 2);
@@ -1857,14 +1859,16 @@ fn commit_partial_by_file() -> Result<()> {
18571859
let list_result = internal::list_virtual_branches(ctx, guard.write_permission())?;
18581860
let branches = list_result.branches;
18591861
let branch1 = &branches.iter().find(|b| b.id == stack1_id).unwrap();
1862+
1863+
but_debugging::git_log(ctx.repo().path(), but_debugging::LogOptions::default().all(true));
18601864

18611865
// branch one test.txt has just the 1st and 3rd hunks applied
18621866
let commit2 = &branch1.series[0].clone()?.patches[0].id;
18631867
let commit2 = ctx
18641868
.repo()
18651869
.find_commit(commit2.to_owned())
18661870
.expect("failed to get commit object");
1867-
1871+
18681872
let tree = commit1.tree().expect("failed to get tree");
18691873
let file_list = tree_to_file_list(ctx.repo(), &tree);
18701874
assert_eq!(file_list, vec!["test.txt", "test2.txt"]);

crates/gitbutler-stack/src/stack.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,16 @@ impl Stack {
317317
.peel_to_commit()?
318318
.id;
319319
let mut revwalk = git2_repository.revwalk()?;
320-
revwalk.hide(self.head(&gix_repo)?)?;
320+
let head_oid = self.head(&gix_repo)?;
321+
revwalk.hide(head_oid)?;
321322
revwalk.push(target_sha.to_git2())?;
322323
revwalk.simplify_first_parent()?;
323-
let last_commit = revwalk.last().ok_or_else(|| anyhow!("fucked"))??;
324-
let last_commit = git2_repository.find_commit(last_commit)?;
325-
let merge_base = last_commit.parent_id(0)?;
326-
Ok(merge_base)
324+
if let Some(last) = revwalk.last() {
325+
let commit = git2_repository.find_commit(last?)?;
326+
Ok(commit.parent_id(0)?)
327+
} else {
328+
Ok(head_oid)
329+
}
327330
}
328331

329332
/// An initialized stack has at least one head (branch).

crates/gitbutler-testsupport/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ gitbutler-stack.workspace = true
3232
but-settings.workspace = true
3333
gitbutler-oxidize.workspace = true
3434
gitbutler-commit.workspace = true
35+
but-debugging.workspace = true
3536
termtree = "0.5.1"
3637
uuid.workspace = true

crates/gitbutler-testsupport/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ pub mod paths {
2727

2828
pub mod virtual_branches {
2929
use gitbutler_command_context::CommandContext;
30+
use gitbutler_oxidize::OidExt;
3031
use gitbutler_stack::{Target, VirtualBranchesHandle};
32+
use gix::refs::transaction::PreviousValue;
3133

3234
use crate::empty_bare_repository;
3335

@@ -49,6 +51,13 @@ pub mod virtual_branches {
4951
})
5052
.expect("failed to write target");
5153

54+
ctx.gix_repository()?.reference(
55+
"refs/remotes/origin/master".to_string(),
56+
remote_repo.head().unwrap().target().unwrap().to_gix(),
57+
PreviousValue::Any,
58+
"",
59+
)?;
60+
5261
gitbutler_branch_actions::update_workspace_commit(&vb_state, ctx)
5362
.expect("failed to update workspace");
5463

0 commit comments

Comments
 (0)