Skip to content

Commit 2869d69

Browse files
committed
Make clear that we get the graph from HEAD!
This might help prevent issues like the one in #11113
1 parent dd98e88 commit 2869d69

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

crates/but-api/src/commands/stack.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ pub fn create_reference(
8181
.transpose()?;
8282

8383
let mut guard = ctx.project().exclusive_worktree_access();
84-
let (repo, mut meta, graph) = ctx.graph_and_meta_mut_and_repo(guard.write_permission())?;
84+
let (repo, mut meta, graph) =
85+
ctx.graph_and_meta_mut_and_repo_from_head(guard.write_permission())?;
8586
let graph = but_workspace::branch::create_reference(
8687
new_ref.clone(),
8788
anchor,
@@ -112,7 +113,8 @@ pub fn create_branch(
112113
if ctx.app_settings().feature_flags.ws3 {
113114
use but_workspace::branch::create_reference::Position::Above;
114115
let mut guard = project.exclusive_worktree_access();
115-
let (repo, mut meta, graph) = ctx.graph_and_meta_mut_and_repo(guard.write_permission())?;
116+
let (repo, mut meta, graph) =
117+
ctx.graph_and_meta_mut_and_repo_from_head(guard.write_permission())?;
116118
let ws = graph.to_workspace()?;
117119
let stack = ws.try_find_stack_by_id(stack_id)?;
118120
let new_ref = Category::LocalBranch
@@ -176,7 +178,8 @@ pub fn remove_branch(
176178
let ctx = CommandContext::open(&project, AppSettings::load_from_default_path_creating()?)?;
177179
let mut guard = project.exclusive_worktree_access();
178180
if ctx.app_settings().feature_flags.ws3 {
179-
let (repo, mut meta, graph) = ctx.graph_and_meta_mut_and_repo(guard.write_permission())?;
181+
let (repo, mut meta, graph) =
182+
ctx.graph_and_meta_mut_and_repo_from_head(guard.write_permission())?;
180183
let ws = graph.to_workspace()?;
181184
let ref_name = Category::LocalBranch
182185
.to_full_name(branch_name.as_str())

crates/but-api/src/commands/virtual_branches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ pub fn create_virtual_branch(
4545
let ws3_enabled = ctx.app_settings().feature_flags.ws3;
4646
let stack_entry = if ws3_enabled {
4747
let mut guard = project.exclusive_worktree_access();
48-
let (repo, mut meta, graph) = ctx.graph_and_meta_mut_and_repo(guard.write_permission())?;
48+
let (repo, mut meta, graph) =
49+
ctx.graph_and_meta_mut_and_repo_from_head(guard.write_permission())?;
4950
let ws = graph.to_workspace()?;
5051
let new_ref = Category::LocalBranch
5152
.to_full_name(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl BranchManager<'_> {
155155
// Assume that this is always about 'apply' and hijack the entire method.
156156
// That way we'd learn what's missing.
157157
if self.ctx.app_settings().feature_flags.apply3 {
158-
let (repo, mut meta, graph) = self.ctx.graph_and_meta_mut_and_repo(perm)?;
158+
let (repo, mut meta, graph) = self.ctx.graph_and_meta_mut_and_repo_from_head(perm)?;
159159
let ws = graph.to_workspace()?;
160160
let target = target.to_string();
161161
let branch_to_apply = target.as_str().try_into()?;

crates/gitbutler-command-context/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl CommandContext {
142142
/// for until the end of the operation for the protection to be effective.
143143
///
144144
/// Use [`Self::graph_and_meta()`] if control over the repository configuration is needed.
145-
pub fn graph_and_meta_mut_and_repo(
145+
pub fn graph_and_meta_mut_and_repo_from_head(
146146
&self,
147147
_write: &mut WorktreeWritePermission,
148148
) -> Result<(

crates/gitbutler-tauri/src/projects.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ fn reconcile_in_workspace_state_of_vb_toml(ctx: &mut CommandContext) -> Option<(
114114
)
115115
.ok()?;
116116
let ws = graph.to_workspace().ok()?;
117-
graph.open_as_svg();
118117

119118
let mut seen = BTreeSet::new();
120119
for in_workspace_stack_id in ws.stacks.iter().filter_map(|s| s.id) {

0 commit comments

Comments
 (0)