Skip to content

Commit 6f4bbc3

Browse files
committed
feat: add key for diff.external.
That way it's conceivable that applications correctly run either a configured external diff tool, or one that is configured on a per diff-driver basis, while being allowed to fall back to a built-in implementation as needed.
1 parent 4aea9b0 commit 6f4bbc3

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

gix/src/config/cache/init.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,16 @@ fn apply_environment_overrides(
530530
(env(key), key.name)
531531
}],
532532
),
533+
#[cfg(feature = "blob-diff")]
534+
(
535+
"diff",
536+
None,
537+
git_prefix,
538+
&[{
539+
let key = &config::tree::Diff::EXTERNAL;
540+
(env(key), key.name)
541+
}],
542+
),
533543
] {
534544
let mut section = env_override
535545
.new_section(section_name, subsection_name)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ impl Diff {
3232
/// The `diff.<driver>.binary` key.
3333
pub const DRIVER_BINARY: Binary = Binary::new_with_validate("binary", &config::Tree::DIFF, validate::Binary)
3434
.with_subsection_requirement(Some(SubSectionRequirement::Parameter("driver")));
35+
36+
/// The `diff.external` key.
37+
pub const EXTERNAL: keys::Program =
38+
keys::Program::new_program("external", &config::Tree::DIFF).with_environment_override("GIT_EXTERNAL_DIFF");
3539
}
3640

3741
impl Section for Diff {
@@ -48,6 +52,7 @@ impl Section for Diff {
4852
&Self::DRIVER_TEXTCONV,
4953
&Self::DRIVER_ALGORITHM,
5054
&Self::DRIVER_BINARY,
55+
&Self::EXTERNAL,
5156
]
5257
}
5358
}

gix/tests/gix-init.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ mod with_overrides {
5050
.set("GIT_ICASE_PATHSPECS", "pathspecs-icase")
5151
.set("GIT_TERMINAL_PROMPT", "42")
5252
.set("GIT_SHALLOW_FILE", "shallow-file-env")
53-
.set("GIT_NAMESPACE", "namespace-env");
53+
.set("GIT_NAMESPACE", "namespace-env")
54+
.set("GIT_EXTERNAL_DIFF", "external-diff-env");
5455
let mut opts = gix::open::Options::isolated()
5556
.cli_overrides([
5657
"http.userAgent=agent-from-cli",
@@ -234,6 +235,8 @@ mod with_overrides {
234235
("gitoxide.http.verbose", "true"),
235236
("gitoxide.allow.protocolFromUser", "file-allowed"),
236237
("core.useReplaceRefs", "no-replace"),
238+
#[cfg(feature = "blob-diff")]
239+
("diff.external", "external-diff-env"),
237240
("gitoxide.objects.replaceRefBase", "refs/replace-mine"),
238241
("gitoxide.committer.nameFallback", "committer name"),
239242
("gitoxide.committer.emailFallback", "committer email"),

0 commit comments

Comments
 (0)