Skip to content

Commit 07c9c96

Browse files
committed
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.
1 parent c5b2746 commit 07c9c96

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use gitbutler_operating_modes::{
2020
};
2121
use gitbutler_oxidize::{git2_to_gix_object_id, gix_to_git2_index, GixRepositoryExt};
2222
use gitbutler_project::access::{WorktreeReadPermission, WorktreeWritePermission};
23-
use gitbutler_project::AUTO_TRACK_LIMIT_BYTES;
2423
use gitbutler_reference::{ReferenceName, Refname};
2524
use gitbutler_repo::{rebase::cherry_rebase, RepositoryExt};
2625
use gitbutler_repo::{signature, SignaturePurpose};
@@ -235,7 +234,9 @@ pub(crate) fn save_and_return_to_workspace(
235234
let parents = commit.parents().collect::<Vec<_>>();
236235

237236
// Recommit commit
238-
let tree = repository.create_wd_tree(AUTO_TRACK_LIMIT_BYTES)?;
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)?;
239240

240241
let (_, committer) = repository.signatures()?;
241242
let commit_headers = commit

crates/gitbutler-project/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ pub fn configure_git2() {
2020
}
2121

2222
/// The maximum size of files to automatically start tracking, i.e. untracked files we pick up for tree-creation.
23-
pub const AUTO_TRACK_LIMIT_BYTES: u64 = 32 * 1024 * 1024;
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/tests/create_wd_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ fn submodule_change() -> anyhow::Result<()> {
575575
fn big_files_check_is_disabled_with_zero() -> anyhow::Result<()> {
576576
let test = TestingRepository::open_with_initial_commit(&[]);
577577

578-
std::fs::write(&test.tempdir.path().join("empty"), "")?;
579-
std::fs::write(&test.tempdir.path().join("with-content"), "content")?;
578+
std::fs::write(test.tempdir.path().join("empty"), "")?;
579+
std::fs::write(test.tempdir.path().join("with-content"), "content")?;
580580

581581
let tree: git2::Tree = test.repository.create_wd_tree(0)?;
582582

0 commit comments

Comments
 (0)