Skip to content

Commit 0072404

Browse files
committed
rename Stack::head() to Stack::head_oid()
This makes it similar to `StackBranch::oid()`
1 parent b5617cc commit 0072404

File tree

30 files changed

+84
-78
lines changed

30 files changed

+84
-78
lines changed

crates/but-workspace/src/commit_engine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn create_commit_and_update_refs(
435435
&& !wsc.inner.parents.contains(&branch_tip) /* the branch tip we know isn't yet merged */
436436
// but the tip is known to the workspace
437437
&& vb.branches.values().any(|s| {
438-
s.head(repo)
438+
s.head_oid(repo)
439439
.is_ok_and(|head_id| head_id == branch_tip)
440440
}) {
441441
let mut stacks: Vec<_> = vb

crates/but-workspace/src/commit_engine/reference_frame.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl ReferenceFrame {
4747
.context("Didn't find stack - was it deleted just now?")?;
4848
Ok(ReferenceFrame {
4949
workspace_tip: Some(head_id.detach()),
50-
branch_tip: Some(stack.head(repo)?),
50+
branch_tip: Some(stack.head_oid(repo)?),
5151
})
5252
}
5353
InferenceMode::CommitIdInStack(commit_id) => {
5454
for stack in vb.branches.values() {
55-
let stack_tip = stack.head(repo)?;
55+
let stack_tip = stack.head_oid(repo)?;
5656
if stack_tip
5757
.attach(repo)
5858
.ancestors()

crates/but-workspace/src/commit_engine/refs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn rewrite(
3535
continue; // Dont rewrite refs for other stacks
3636
}
3737
}
38-
if stack.head(repo)? == old {
38+
if stack.head_oid(repo)? == old {
3939
// Perhaps skip this - the head will be updated later in this call
4040
// stack.set_stack_head_without_persisting(repo, new.to_git2(), None)?;
4141
// Does it make sense to set stack tree in v3? I think not

crates/but-workspace/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl StackEntry {
140140
Ok(StackEntry {
141141
id: stack.id,
142142
heads: stack_heads_info(stack, repo)?,
143-
tip: stack.head(repo)?,
143+
tip: stack.head_oid(repo)?,
144144
})
145145
}
146146
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub fn create_virtual_branch(
111111
Ok(StackEntry {
112112
id: stack.id,
113113
heads: stack_heads_info(&stack, &repo)?,
114-
tip: stack.head(&repo)?,
114+
tip: stack.head_oid(&repo)?,
115115
})
116116
}
117117

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn go_back_to_integration(ctx: &CommandContext, default_target: &Target) -> Resu
8282
for branch in &virtual_branches {
8383
// merge this branches tree with our tree
8484
let branch_tree_id = git2_to_gix_object_id(
85-
repo.find_commit(branch.head(&gix_repo)?.to_git2())
85+
repo.find_commit(branch.head_oid(&gix_repo)?.to_git2())
8686
.context("failed to find branch head")?
8787
.tree_id(),
8888
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn branch_group_to_branch(
298298
// If there is a virtual branch let's get it's head. Alternatively, pick the first local branch and use it's head.
299299
// If there are no local branches, pick the first remote branch.
300300
let head_commit = if let Some(vbranch) = virtual_branch {
301-
Some(vbranch.head(repo)?.attach(repo))
301+
Some(vbranch.head_oid(repo)?.attach(repo))
302302
} else if let Some(mut branch) = local_branches.into_iter().next() {
303303
branch.peel_to_id_in_place_packed(packed).ok()
304304
} else if let Some(mut branch) = remote_branches.into_iter().next() {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ impl BranchManager<'_> {
289289

290290
let gix_repo = repo.to_gix()?;
291291
let merge_base = repo
292-
.merge_base(default_target.sha, stack.head(&gix_repo)?.to_git2())
292+
.merge_base(default_target.sha, stack.head_oid(&gix_repo)?.to_git2())
293293
.context(format!(
294294
"failed to find merge base between {} and {}",
295295
default_target.sha,
296-
stack.head(&gix_repo)?
296+
stack.head_oid(&gix_repo)?
297297
))?;
298298

299299
// Branch is out of date, merge or rebase it
@@ -331,7 +331,7 @@ impl BranchManager<'_> {
331331
// Do we need to rebase the branch on top of the default target?
332332

333333
let has_change_id = repo
334-
.find_commit(stack.head(&gix_repo)?.to_git2())?
334+
.find_commit(stack.head_oid(&gix_repo)?.to_git2())?
335335
.change_id()
336336
.is_some();
337337
// If the branch has no change ID for the head commit, we want to rebase it even if the base is the same
@@ -351,7 +351,7 @@ impl BranchManager<'_> {
351351
} else {
352352
gitbutler_merge_commits(
353353
repo,
354-
repo.find_commit(stack.head(&gix_repo)?.to_git2())?,
354+
repo.find_commit(stack.head_oid(&gix_repo)?.to_git2())?,
355355
repo.find_commit(default_target.sha)?,
356356
&stack.name,
357357
default_target.branch.branch(),
@@ -378,7 +378,8 @@ impl BranchManager<'_> {
378378

379379
{
380380
if let Some(wip_commit_to_unapply) = &stack.not_in_workspace_wip_change_id {
381-
let potential_wip_commit = repo.find_commit(stack.head(&gix_repo)?.to_git2())?;
381+
let potential_wip_commit =
382+
repo.find_commit(stack.head_oid(&gix_repo)?.to_git2())?;
382383

383384
// Don't try to undo commit if its conflicted
384385
if !potential_wip_commit.is_conflicted() {
@@ -387,7 +388,7 @@ impl BranchManager<'_> {
387388
stack = crate::undo_commit::undo_commit(
388389
self.ctx,
389390
stack.id,
390-
stack.head(&gix_repo)?.to_git2(),
391+
stack.head_oid(&gix_repo)?.to_git2(),
391392
perm,
392393
)?;
393394
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ impl BranchManager<'_> {
7777
let workspace_base = gix_repo
7878
.find_commit(workspace_base(self.ctx, perm.read_permission())?)?
7979
.tree_id()?;
80-
let stack_head = gix_repo.find_commit(stack.head(&gix_repo)?)?.tree_id()?;
80+
let stack_head = gix_repo
81+
.find_commit(stack.head_oid(&gix_repo)?)?
82+
.tree_id()?;
8183

8284
let mut merge = gix_repo.merge_trees(
8385
stack_head,
@@ -95,7 +97,7 @@ impl BranchManager<'_> {
9597
.context("failed to checkout tree")?;
9698
} else {
9799
let gix_repo = self.ctx.gix_repo()?;
98-
let head = stack.head(&gix_repo)?;
100+
let head = stack.head_oid(&gix_repo)?;
99101
let head = repo.find_commit(head.to_git2())?;
100102

101103
// If there are uncommited changes, we should make a wip commit.
@@ -128,7 +130,7 @@ impl BranchManager<'_> {
128130
.collect::<Vec<(PathBuf, Vec<VirtualBranchHunk>)>>();
129131
let tree_oid = gitbutler_diff::write::hunks_onto_oid(
130132
self.ctx,
131-
stack.head(&gix_repo)?.to_git2(),
133+
stack.head_oid(&gix_repo)?.to_git2(),
132134
files,
133135
)?;
134136
let mut merge = gix_repo.merge_trees(
@@ -184,7 +186,7 @@ impl BranchManager<'_> {
184186
// Build wip tree as either any uncommitted changes or an empty tree
185187
let vbranch_wip_tree = repo.find_tree(stack.tree(self.ctx)?)?;
186188
let vbranch_head_tree = repo
187-
.find_commit(stack.head(&repo.to_gix()?)?.to_git2())?
189+
.find_commit(stack.head_oid(&repo.to_gix()?)?.to_git2())?
188190
.tree()?;
189191

190192
let tree = if vbranch_head_tree.id() != vbranch_wip_tree.id() {
@@ -201,7 +203,7 @@ impl BranchManager<'_> {
201203
// Commit wip commit
202204
let committer = gitbutler_repo::signature(SignaturePurpose::Committer)?;
203205
let author = gitbutler_repo::signature(SignaturePurpose::Author)?;
204-
let parent = stack.head(&gix_repo)?;
206+
let parent = stack.head_oid(&gix_repo)?;
205207
let parent = repo.find_commit(parent.to_git2())?;
206208

207209
let commit_headers = CommitHeadersV2::new();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn integrate_upstream_commits_for_series(
6666
let integrate_upstream_context = IntegrateUpstreamContext {
6767
repo,
6868
target_branch_head: default_target.sha,
69-
branch_head: stack.head(&gix_repo)?.to_git2(),
69+
branch_head: stack.head_oid(&gix_repo)?.to_git2(),
7070
branch_tree: stack.tree(ctx)?,
7171
branch_name: subject_branch.name(),
7272
branch_full_name: subject_branch.full_name()?,

0 commit comments

Comments
 (0)