Skip to content

Commit 85a24b3

Browse files
committed
feat: add gitoxide.parsePrecious configuration key to opt-in to precious file parsing.
1 parent 828e903 commit 85a24b3

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

gix/src/config/cache/access.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,20 @@ impl Cache {
396396
Some(user_path) => Some(user_path),
397397
None => self.xdg_config_path("ignore")?,
398398
};
399+
let parse_ignore = gix_ignore::search::Ignore {
400+
support_precious: boolean(
401+
self,
402+
"gitoxide.parsePrecious",
403+
&config::tree::Gitoxide::PARSE_PRECIOUS,
404+
false,
405+
)?,
406+
};
399407
Ok(gix_worktree::stack::state::Ignore::new(
400408
overrides.unwrap_or_default(),
401-
gix_ignore::Search::from_git_dir(git_dir, excludes_file, buf)?,
409+
gix_ignore::Search::from_git_dir(git_dir, excludes_file, buf, parse_ignore)?,
402410
None,
403411
source,
412+
parse_ignore,
404413
))
405414
}
406415
// TODO: at least one test, maybe related to core.attributesFile configuration.

gix/src/config/cache/init.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,16 @@ fn apply_environment_overrides(
357357
"gitoxide",
358358
None,
359359
git_prefix,
360-
&[{
361-
let key = &Gitoxide::TRACE_PACKET;
362-
(env(key), key.name)
363-
}],
360+
&[
361+
{
362+
let key = &Gitoxide::TRACE_PACKET;
363+
(env(key), key.name)
364+
},
365+
{
366+
let key = &Gitoxide::PARSE_PRECIOUS;
367+
(env(key), key.name)
368+
},
369+
],
364370
),
365371
(
366372
"gitoxide",

gix/src/config/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ pub mod command_context {
239239

240240
///
241241
pub mod exclude_stack {
242+
use crate::config;
242243
use std::path::PathBuf;
243244

244245
/// The error produced when setting up a stack to query `gitignore` information.
@@ -251,6 +252,8 @@ pub mod exclude_stack {
251252
EnvironmentPermission(#[from] gix_sec::permission::Error<PathBuf>),
252253
#[error("The value for `core.excludesFile` could not be read from configuration")]
253254
ExcludesFilePathInterpolation(#[from] gix_config::path::interpolate::Error),
255+
#[error(transparent)]
256+
ParsePreciousEnabled(#[from] config::boolean::Error),
254257
}
255258
}
256259

gix/src/config/tree/sections/gitoxide.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ impl Gitoxide {
3636
/// The `gitoxide.tracePacket` Key.
3737
pub const TRACE_PACKET: keys::Boolean = keys::Boolean::new_boolean("tracePacket", &config::Tree::GITOXIDE)
3838
.with_environment_override("GIT_TRACE_PACKET");
39+
/// The `gitoxide.parsePrecious` Key.
40+
pub const PARSE_PRECIOUS: keys::Boolean = keys::Boolean::new_boolean("parsePrecious", &config::Tree::GITOXIDE)
41+
.with_environment_override("GIX_PARSE_PRECIOUS");
3942
}
4043

4144
impl Section for Gitoxide {
@@ -44,7 +47,7 @@ impl Section for Gitoxide {
4447
}
4548

4649
fn keys(&self) -> &[&dyn Key] {
47-
&[&Self::USER_AGENT, &Self::TRACE_PACKET]
50+
&[&Self::USER_AGENT, &Self::TRACE_PACKET, &Self::PARSE_PRECIOUS]
4851
}
4952

5053
fn sub_sections(&self) -> &[&dyn Section] {

gix/tests/gix-init.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ mod with_overrides {
5252
.set("GIT_AUTHOR_DATE", default_date)
5353
.set("EMAIL", "user email")
5454
.set("GIX_PACK_CACHE_MEMORY", "0")
55+
.set("GIX_PARSE_PRECIOUS", "1")
5556
.set("GIX_OBJECT_CACHE_MEMORY", "5m")
5657
.set("GIX_CREDENTIALS_HELPER_STDERR", "creds-stderr")
5758
.set("GIX_EXTERNAL_COMMAND_STDERR", "filter-stderr")
@@ -244,6 +245,7 @@ mod with_overrides {
244245
("gitoxide.commit.authorDate", default_date),
245246
("gitoxide.commit.committerDate", default_date),
246247
("gitoxide.user.emailFallback", "user email"),
248+
("gitoxide.parsePrecious", "1"),
247249
("core.deltaBaseCacheLimit", "0"),
248250
("gitoxide.objects.cacheLimit", "5m"),
249251
("gitoxide.pathspec.icase", "pathspecs-icase"),

0 commit comments

Comments
 (0)