Skip to content

Commit fb633cc

Browse files
committed
Keep using get_workspace_head() when no cached result is used.
That way, the application will not run into unexpected cases.
1 parent 79798c7 commit fb633cc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{collections::HashMap, path::PathBuf, vec};
22

3+
use crate::integration::get_workspace_head;
34
use crate::{
45
conflicts::RepoConflictsExt,
56
file::{virtual_hunks_into_virtual_files, VirtualBranchFile},
@@ -16,7 +17,6 @@ use gitbutler_command_context::CommandContext;
1617
use gitbutler_diff::{diff_files_into_hunks, GitHunk, Hunk, HunkHash};
1718
use gitbutler_operating_modes::assure_open_workspace_mode;
1819
use gitbutler_project::access::WorktreeWritePermission;
19-
use gitbutler_repo::RepositoryExt;
2020
use tracing::instrument;
2121

2222
/// Represents the uncommitted status of the applied virtual branches in the workspace.
@@ -52,11 +52,10 @@ pub fn get_applied_status_cached(
5252
.virtual_branches()
5353
.list_branches_in_workspace()?;
5454
let base_file_diffs = worktree_changes.map(Ok).unwrap_or_else(|| {
55-
// TODO(ST): this was `get_workspace_head()`, which is slow and ideally, we don't dynamically
56-
// calculate which should already be 'fixed' - why do we have the integration branch
57-
// if we can't assume it's in the right state? So ideally, we assure that the code
58-
// that affects the integration branch also updates it?
59-
let integration_commit_id = ctx.repository().head_commit()?.id();
55+
// TODO(ST): Ideally, we can avoid calling `get_workspace_head()` as everyone who modifies
56+
// any of its inputs will update the intragration commit right away.
57+
// It's for another day though - right now the integration commit may be slightly stale.
58+
let integration_commit_id = get_workspace_head(ctx)?;
6059
gitbutler_diff::workdir(ctx.repository(), &integration_commit_id.to_owned())
6160
.context("failed to diff workdir")
6261
})?;

0 commit comments

Comments
 (0)