Skip to content

Commit 394924b

Browse files
committed
feat: add Repository::big_file_threshold() to easily learn what Git considers a big file.
1 parent 1ccbeef commit 394924b

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

gix/src/repository/config/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ impl crate::Repository {
4242
&self.options
4343
}
4444

45+
/// Return the big-file threshold above which Git will not perform a diff anymore or try to delta-diff packs,
46+
/// as configured by `core.bigFileThreshold`, or the default value.
47+
pub fn big_file_threshold(&self) -> Result<u64, config::unsigned_integer::Error> {
48+
self.config.big_file_threshold()
49+
}
50+
4551
/// Obtain options for use when connecting via `ssh`.
4652
#[cfg(feature = "blocking-network-client")]
4753
pub fn ssh_connect_options(
Binary file not shown.

gix/tests/fixtures/make_config_repos.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,8 @@ EOF
192192
echo $'[remote "any"]\n\turl=anyurl' >>config
193193

194194
)
195+
196+
git init big-file-threshold
197+
(cd big-file-threshold
198+
git config core.bigFileThreshold 42
199+
)

gix/tests/gix/repository/config/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ mod config_snapshot;
22
mod identity;
33
mod remote;
44

5+
#[test]
6+
#[cfg(feature = "blocking-network-client")]
7+
fn big_file_threshold() -> crate::Result {
8+
let repo = repo("with-hasconfig");
9+
assert_eq!(
10+
repo.big_file_threshold()?,
11+
512 * 1024 * 1024,
12+
"Git really handles huge files, and this is the default"
13+
);
14+
15+
let repo = crate::repository::config::repo("big-file-threshold");
16+
assert_eq!(repo.big_file_threshold()?, 42, "It picks up configured values as well");
17+
Ok(())
18+
}
19+
520
#[cfg(feature = "blocking-network-client")]
621
mod ssh_options {
722
use std::ffi::OsStr;

0 commit comments

Comments
 (0)