Skip to content

Commit f3257f3

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

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

gix/src/config/cache/access.rs

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ impl Cache {
162162
.copied()
163163
}
164164

165-
#[cfg(feature = "blob-diff")]
166165
pub(crate) fn big_file_threshold(&self) -> Result<u64, config::unsigned_integer::Error> {
167166
Ok(self
168167
.resolved

gix/src/repository/config/mod.rs

+6
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

+5
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

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ mod config_snapshot;
22
mod identity;
33
mod remote;
44

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

41-
#[cfg(feature = "blocking-network-client")]
4255
pub fn repo(name: &str) -> gix::Repository {
4356
repo_opts(name, |opts| opts.strict_config(true))
4457
}
4558

46-
#[cfg(feature = "blocking-network-client")]
4759
pub fn repo_opts(name: &str, modify: impl FnOnce(gix::open::Options) -> gix::open::Options) -> gix::Repository {
4860
let dir = gix_testtools::scripted_fixture_read_only("make_config_repos.sh").unwrap();
4961
gix::open_opts(dir.join(name), modify(gix::open::Options::isolated())).unwrap()

0 commit comments

Comments
 (0)