Skip to content

Commit fa67ead

Browse files
authored
Merge pull request #5889 from Byron/gix-status-for-create-wd-tree
use `gix-status` for `create_wd_tree()`
2 parents 8939217 + 07c9c96 commit fa67ead

File tree

16 files changed

+1053
-520
lines changed

16 files changed

+1053
-520
lines changed

Cargo.lock

Lines changed: 255 additions & 182 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ resolver = "2"
4343
[workspace.dependencies]
4444
bstr = "1.11.1"
4545
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
46-
gix = { git = "https://github.com/GitoxideLabs/gitoxide", rev = "faa0cdeb35a8135ff9513a1c9884126f6b080f4a", default-features = false, features = [] }
46+
gix = { git = "https://github.com/GitoxideLabs/gitoxide", rev = "af704f57bb9480c47cdd393465264d586f1d4562", default-features = false, features = [] }
4747
git2 = { version = "0.20.0", features = [
4848
"vendored-openssl",
4949
"vendored-libgit2",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use gitbutler_error::error::Marker;
1313
use gitbutler_oplog::SnapshotExt;
1414
use gitbutler_oxidize::GixRepositoryExt;
1515
use gitbutler_project::access::WorktreeWritePermission;
16+
use gitbutler_project::AUTO_TRACK_LIMIT_BYTES;
1617
use gitbutler_reference::{Refname, RemoteRefname};
1718
use gitbutler_repo::logging::{LogUntil, RepositoryExt as _};
1819
use gitbutler_repo::{
@@ -305,7 +306,7 @@ impl BranchManager<'_> {
305306

306307
// We don't support having two branches applied that conflict with each other
307308
{
308-
let uncommited_changes_tree_id = repo.create_wd_tree()?.id();
309+
let uncommited_changes_tree_id = repo.create_wd_tree(AUTO_TRACK_LIMIT_BYTES)?.id();
309310
let gix_repo = self.ctx.gix_repository_for_merging_non_persisting()?;
310311
let merges_cleanly = gix_repo
311312
.merges_cleanly_compat(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use gitbutler_oxidize::{
2626
git2_signature_to_gix_signature, git2_to_gix_object_id, gix_to_git2_oid, GixRepositoryExt,
2727
};
2828
use gitbutler_project::access::WorktreeWritePermission;
29+
use gitbutler_project::AUTO_TRACK_LIMIT_BYTES;
2930
use gitbutler_reference::{normalize_branch_name, Refname, RemoteRefname};
3031
use gitbutler_repo::{
3132
logging::{LogUntil, RepositoryExt as _},
@@ -1091,7 +1092,7 @@ pub fn is_remote_branch_mergeable(
10911092

10921093
let base_tree = find_base_tree(ctx.repo(), &branch_commit, &target_commit)?;
10931094

1094-
let wd_tree = ctx.repo().create_wd_tree()?;
1095+
let wd_tree = ctx.repo().create_wd_tree(AUTO_TRACK_LIMIT_BYTES)?;
10951096

10961097
let branch_tree = branch_commit.tree().context("failed to find branch tree")?;
10971098
let gix_repo_in_memory = ctx.gix_repository_for_merging()?.with_object_memory();

crates/gitbutler-edit-mode/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ pub(crate) fn save_and_return_to_workspace(
234234
let parents = commit.parents().collect::<Vec<_>>();
235235

236236
// Recommit commit
237-
let tree = repository.create_wd_tree()?;
237+
// While we perform hard resets we should pick up everything to avoid loosing worktree state.
238+
let pick_up_untracked_files_of_any_size = 0;
239+
let tree = repository.create_wd_tree(pick_up_untracked_files_of_any_size)?;
238240

239241
let (_, committer) = repository.signatures()?;
240242
let commit_headers = commit

crates/gitbutler-oplog/src/oplog.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use gitbutler_oxidize::{
2020
};
2121
use gitbutler_project::{
2222
access::{WorktreeReadPermission, WorktreeWritePermission},
23-
Project,
23+
Project, AUTO_TRACK_LIMIT_BYTES,
2424
};
2525
use gitbutler_repo::RepositoryExt;
2626
use gitbutler_repo::SignaturePurpose;
@@ -30,8 +30,6 @@ use gix::object::tree::diff::Change;
3030
use gix::prelude::ObjectIdExt;
3131
use tracing::instrument;
3232

33-
const SNAPSHOT_FILE_LIMIT_BYTES: u64 = 32 * 1024 * 1024;
34-
3533
/// The Oplog allows for crating snapshots of the current state of the project as well as restoring to a previous snapshot.
3634
/// Snapshots include the state of the working directory as well as all additional GitButler state (e.g. virtual branches, conflict state).
3735
/// The data is stored as git trees in the following shape:
@@ -312,7 +310,7 @@ impl OplogExt for Project {
312310
let old_wd_tree_id = tree_from_applied_vbranches(&gix_repo, commit.parent(0)?.id())?;
313311
let old_wd_tree = repo.find_tree(old_wd_tree_id)?;
314312

315-
repo.ignore_large_files_in_diffs(SNAPSHOT_FILE_LIMIT_BYTES)?;
313+
repo.ignore_large_files_in_diffs(AUTO_TRACK_LIMIT_BYTES)?;
316314

317315
let mut diff_opts = git2::DiffOptions::new();
318316
diff_opts
@@ -602,7 +600,7 @@ fn restore_snapshot(
602600
let workdir_tree_id = tree_from_applied_vbranches(&gix_repo, snapshot_commit_id)?;
603601
let workdir_tree = repo.find_tree(workdir_tree_id)?;
604602

605-
repo.ignore_large_files_in_diffs(SNAPSHOT_FILE_LIMIT_BYTES)?;
603+
repo.ignore_large_files_in_diffs(AUTO_TRACK_LIMIT_BYTES)?;
606604

607605
// Define the checkout builder
608606
let mut checkout_builder = git2::build::CheckoutBuilder::new();
@@ -739,7 +737,7 @@ fn lines_since_snapshot(project: &Project, repo: &git2::Repository) -> Result<us
739737
// This looks at the diff between the tree of the currently selected as 'default' branch (where new changes go)
740738
// and that same tree in the last snapshot. For some reason, comparing workdir to the workdir subree from
741739
// the snapshot simply does not give us what we need here, so instead using tree to tree comparison.
742-
repo.ignore_large_files_in_diffs(SNAPSHOT_FILE_LIMIT_BYTES)?;
740+
repo.ignore_large_files_in_diffs(AUTO_TRACK_LIMIT_BYTES)?;
743741

744742
let oplog_state = OplogHandle::new(&project.gb_dir());
745743
let Some(oplog_commit_id) = oplog_state.oplog_head()? else {

crates/gitbutler-project/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ pub fn configure_git2() {
1818
// These settings are only changed from `main` of applications.
1919
git2::opts::strict_object_creation(false);
2020
}
21+
22+
/// The maximum size of files to automatically start tracking, i.e. untracked files we pick up for tree-creation.
23+
/// **Inactive for now** while it's hard to tell if it's safe *not* to pick up everything.
24+
pub const AUTO_TRACK_LIMIT_BYTES: u64 = 0;

crates/gitbutler-repo/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ path = "tests/mod.rs"
3939
gitbutler-testsupport.workspace = true
4040
gitbutler-user.workspace = true
4141
serde_json = { version = "1.0", features = ["std", "arbitrary_precision"] }
42+
insta = "1.41.1"

0 commit comments

Comments
 (0)