From d0d803cf19ab23ff3c4c9a1e835e6021c6b67a76 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 6 Jan 2025 07:25:28 +0100 Subject: [PATCH] Effectively assure that `create_wd_tree()` picks up everything. It's not safe to do that while performing hard resets, and we shouldn't risk it just yet. --- crates/gitbutler-edit-mode/src/lib.rs | 4 +++- crates/gitbutler-project/src/lib.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/gitbutler-edit-mode/src/lib.rs b/crates/gitbutler-edit-mode/src/lib.rs index 2101c7db82..fa2b146e53 100644 --- a/crates/gitbutler-edit-mode/src/lib.rs +++ b/crates/gitbutler-edit-mode/src/lib.rs @@ -235,7 +235,9 @@ pub(crate) fn save_and_return_to_workspace( let parents = commit.parents().collect::>(); // Recommit commit - let tree = repository.create_wd_tree(AUTO_TRACK_LIMIT_BYTES)?; + // While we perform hard resets we should pick up everything to avoid loosing worktree state. + let pick_up_untracked_files_of_any_size = 0; + let tree = repository.create_wd_tree(pick_up_untracked_files_of_any_size)?; let (_, committer) = repository.signatures()?; let commit_headers = commit diff --git a/crates/gitbutler-project/src/lib.rs b/crates/gitbutler-project/src/lib.rs index 1b08f51143..aba2c3cc71 100644 --- a/crates/gitbutler-project/src/lib.rs +++ b/crates/gitbutler-project/src/lib.rs @@ -20,4 +20,5 @@ pub fn configure_git2() { } /// The maximum size of files to automatically start tracking, i.e. untracked files we pick up for tree-creation. -pub const AUTO_TRACK_LIMIT_BYTES: u64 = 32 * 1024 * 1024; +/// **Inactive for now** while it's hard to tell if it's safe *not* to pick up everything. +pub const AUTO_TRACK_LIMIT_BYTES: u64 = 0;