Skip to content

Commit e011e36

Browse files
committed
feat!: respect core.useReplaceRefs and remove gitoxide.objects.noReplace.
The gitoxide specific variable wasn't needed in the first place.
1 parent f3193c9 commit e011e36

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

gix/src/config/cache/init.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,6 @@ fn apply_environment_overrides(
426426
Some(Cow::Borrowed("objects".into())),
427427
objects,
428428
&[
429-
{
430-
let key = &gitoxide::Objects::NO_REPLACE;
431-
(env(key), key.name)
432-
},
433429
{
434430
let key = &gitoxide::Objects::REPLACE_REF_BASE;
435431
(env(key), key.name)
@@ -491,6 +487,10 @@ fn apply_environment_overrides(
491487
let key = &Core::SSH_COMMAND;
492488
(env(key), key.name, git_prefix)
493489
},
490+
{
491+
let key = &Core::USE_REPLACE_REFS;
492+
(env(key), key.name, objects)
493+
},
494494
] {
495495
if let Some(value) = var_as_bstring(var, permission) {
496496
section.push_with_comment(

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

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ impl Core {
6363
/// The `core.sshCommand` key.
6464
pub const SSH_COMMAND: keys::Executable = keys::Executable::new_executable("sshCommand", &config::Tree::CORE)
6565
.with_environment_override("GIT_SSH_COMMAND");
66+
/// The `core.useReplaceRefs` key.
67+
pub const USE_REPLACE_REFS: keys::Boolean = keys::Boolean::new_boolean("useReplaceRefs", &config::Tree::CORE)
68+
.with_environment_override("GIT_NO_REPLACE_OBJECTS");
6669
}
6770

6871
impl Section for Core {
@@ -92,6 +95,7 @@ impl Section for Core {
9295
&Self::EXCLUDES_FILE,
9396
&Self::ATTRIBUTES_FILE,
9497
&Self::SSH_COMMAND,
98+
&Self::USE_REPLACE_REFS,
9599
]
96100
}
97101
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ mod subsections {
317317
.with_note("If unset or 0, there is no object cache")
318318
.with_environment_override("GITOXIDE_OBJECT_CACHE_MEMORY");
319319
/// The `gitoxide.objects.noReplace` key.
320-
pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS)
321-
.with_environment_override("GIT_NO_REPLACE_OBJECTS");
320+
pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS);
322321
/// The `gitoxide.objects.replaceRefBase` key.
323322
pub const REPLACE_REF_BASE: keys::Any =
324323
keys::Any::new("replaceRefBase", &Gitoxide::OBJECTS).with_environment_override("GIT_REPLACE_REF_BASE");
@@ -330,7 +329,7 @@ mod subsections {
330329
}
331330

332331
fn keys(&self) -> &[&dyn Key] {
333-
&[&Self::CACHE_LIMIT, &Self::NO_REPLACE, &Self::REPLACE_REF_BASE]
332+
&[&Self::CACHE_LIMIT, &Self::REPLACE_REF_BASE]
334333
}
335334

336335
fn parent(&self) -> Option<&dyn Section> {

gix/src/open/repository.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ fn replacement_objects_refs_prefix(
284284
mut filter_config_section: fn(&gix_config::file::Metadata) -> bool,
285285
) -> Result<Option<PathBuf>, Error> {
286286
let is_disabled = config
287-
.boolean_filter_by_key("gitoxide.objects.noReplace", &mut filter_config_section)
288-
.map(|b| gitoxide::Objects::NO_REPLACE.enrich_error(b))
287+
.boolean_filter_by_key("core.useReplaceRefs", &mut filter_config_section)
288+
.map(|b| Core::USE_REPLACE_REFS.enrich_error(b))
289289
.transpose()
290290
.with_leniency(lenient)
291291
.map_err(config::Error::ConfigBoolean)?
292-
.unwrap_or_default();
292+
.unwrap_or(true);
293293

294294
if is_disabled {
295295
return Ok(None);

gix/tests/repository/open.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ mod with_overrides {
394394
for (key, expected) in [
395395
("gitoxide.http.verbose", "true"),
396396
("gitoxide.allow.protocolFromUser", "file-allowed"),
397-
("gitoxide.objects.noReplace", "no-replace"),
397+
("core.useReplaceRefs", "no-replace"),
398398
("gitoxide.objects.replaceRefBase", "refs/replace-mine"),
399399
("gitoxide.committer.nameFallback", "committer name"),
400400
("gitoxide.committer.emailFallback", "committer email"),

0 commit comments

Comments
 (0)