Skip to content

Commit dd98e88

Browse files
committed
Reconcile stacks for the gitbutler/workspace, not for the HEAD workspace.
1 parent 8fad61a commit dd98e88

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,35 @@ impl CommandContext {
156156
Ok((repo, VirtualBranchesTomlMetadataMut(meta), graph))
157157
}
158158

159+
/// Open the repository with standard options and create a new Graph traversal from the given `ref_name`,
160+
/// along with a new metadata instance, and the graph itself.
161+
///
162+
/// The write-permission is required to obtain a mutable metadata instance. Note that it must be held
163+
/// for until the end of the operation for the protection to be effective.
164+
///
165+
/// Use [`Self::graph_and_meta()`] if control over the repository configuration is needed.
166+
pub fn graph_and_meta_mut_and_repo_from_reference(
167+
&self,
168+
ref_name: &gix::refs::FullNameRef,
169+
_write: &mut WorktreeWritePermission,
170+
) -> Result<(
171+
gix::Repository,
172+
VirtualBranchesTomlMetadataMut,
173+
but_graph::Graph,
174+
)> {
175+
let repo = self.gix_repo()?;
176+
let meta = self.meta_inner()?;
177+
let mut reference = repo.find_reference(ref_name)?;
178+
let commit_id = reference.peel_to_commit()?.id();
179+
let graph = but_graph::Graph::from_commit_traversal(
180+
commit_id,
181+
reference.name().to_owned(),
182+
&meta,
183+
meta.graph_options(),
184+
)?;
185+
Ok((repo, VirtualBranchesTomlMetadataMut(meta), graph))
186+
}
187+
159188
/// Return a newly opened `gitoxide` repository, with all configuration available
160189
/// to correctly figure out author and committer names (i.e. with most global configuration loaded),
161190
/// *and* which will perform diffs quickly thanks to an adequate object cache.

crates/gitbutler-tauri/src/projects.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,16 @@ pub fn set_project_active(
105105
fn reconcile_in_workspace_state_of_vb_toml(ctx: &mut CommandContext) -> Option<()> {
106106
let mut guard = ctx.project().exclusive_worktree_access();
107107
let perm = guard.write_permission();
108-
let (_repo, mut meta, graph) = ctx.graph_and_meta_mut_and_repo(perm).ok()?;
108+
let (_repo, mut meta, graph) = ctx
109+
.graph_and_meta_mut_and_repo_from_reference(
110+
"refs/heads/gitbutler/workspace"
111+
.try_into()
112+
.expect("statically known to be valid"),
113+
perm,
114+
)
115+
.ok()?;
109116
let ws = graph.to_workspace().ok()?;
117+
graph.open_as_svg();
110118

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

0 commit comments

Comments
 (0)