History

feat!: respect `core.useReplaceRefs` and remove `gitoxide.objects.noReplace`.

The gitoxide specific variable wasn't needed in the first place.

Sebastian Thiel committed 3 years ago

Commit e011e361 parent f3193c95 files · +14 −11Browse files

Unified · Split

5 files
  1. gix/src/config/cache/init.rs +4 −4
  2. gix/src/config/tree/sections/core.rs +4 −0
  3. gix/src/config/tree/sections/gitoxide.rs +2 −3
  4. gix/src/open/repository.rs +3 −3
  5. gix/tests/repository/open.rs +1 −1
gix/src/config/cache/init.rs+4−4
@@ -426,10 +426,6 @@ fn apply_environment_overrides( · 425 unmodified lines
426 Some(Cow::Borrowed("objects".into())),426 Some(Cow::Borrowed("objects".into())),
427 objects,427 objects,
428 &[428 &[
429 {
430 let key = &gitoxide::Objects::NO_REPLACE;
431 (env(key), key.name)
432 },
433 {429 {
434 let key = &gitoxide::Objects::REPLACE_REF_BASE;430 let key = &gitoxide::Objects::REPLACE_REF_BASE;
435 (env(key), key.name)431 (env(key), key.name)
@@ -491,6 +487,10 @@ fn apply_environment_overrides( · 55 unmodified lines
491 let key = &Core::SSH_COMMAND;487 let key = &Core::SSH_COMMAND;
492 (env(key), key.name, git_prefix)488 (env(key), key.name, git_prefix)
493 },489 },
490 {
491 let key = &Core::USE_REPLACE_REFS;
492 (env(key), key.name, objects)
493 },
494 ] {494 ] {
495 if let Some(value) = var_as_bstring(var, permission) {495 if let Some(value) = var_as_bstring(var, permission) {
496 section.push_with_comment(496 section.push_with_comment(
gix/src/config/tree/sections/core.rs+4−0
@@ -63,6 +63,9 @@ impl Core { · 62 unmodified lines
63 /// The `core.sshCommand` key.63 /// The `core.sshCommand` key.
64 pub const SSH_COMMAND: keys::Executable = keys::Executable::new_executable("sshCommand", &config::Tree::CORE)64 pub const SSH_COMMAND: keys::Executable = keys::Executable::new_executable("sshCommand", &config::Tree::CORE)
65 .with_environment_override("GIT_SSH_COMMAND");65 .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");
66}69}
67 70
68impl Section for Core {71impl Section for Core {
@@ -92,6 +95,7 @@ impl Section for Core { · 23 unmodified lines
92 &Self::EXCLUDES_FILE,95 &Self::EXCLUDES_FILE,
93 &Self::ATTRIBUTES_FILE,96 &Self::ATTRIBUTES_FILE,
94 &Self::SSH_COMMAND,97 &Self::SSH_COMMAND,
98 &Self::USE_REPLACE_REFS,
95 ]99 ]
96 }100 }
97}101}
gix/src/config/tree/sections/gitoxide.rs+2−3
@@ -317,8 +317,7 @@ mod subsections { · 316 unmodified lines
317 .with_note("If unset or 0, there is no object cache")317 .with_note("If unset or 0, there is no object cache")
318 .with_environment_override("GITOXIDE_OBJECT_CACHE_MEMORY");318 .with_environment_override("GITOXIDE_OBJECT_CACHE_MEMORY");
319 /// The `gitoxide.objects.noReplace` key.319 /// The `gitoxide.objects.noReplace` key.
320 pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS)320 pub const NO_REPLACE: keys::Boolean = keys::Boolean::new_boolean("noReplace", &Gitoxide::OBJECTS);
321 .with_environment_override("GIT_NO_REPLACE_OBJECTS");
322 /// The `gitoxide.objects.replaceRefBase` key.321 /// The `gitoxide.objects.replaceRefBase` key.
323 pub const REPLACE_REF_BASE: keys::Any =322 pub const REPLACE_REF_BASE: keys::Any =
324 keys::Any::new("replaceRefBase", &Gitoxide::OBJECTS).with_environment_override("GIT_REPLACE_REF_BASE");323 keys::Any::new("replaceRefBase", &Gitoxide::OBJECTS).with_environment_override("GIT_REPLACE_REF_BASE");
@@ -330,7 +329,7 @@ mod subsections { · 5 unmodified lines
330 }329 }
331 330
332 fn keys(&self) -> &[&dyn Key] {331 fn keys(&self) -> &[&dyn Key] {
333 &[&Self::CACHE_LIMIT, &Self::NO_REPLACE, &Self::REPLACE_REF_BASE]332 &[&Self::CACHE_LIMIT, &Self::REPLACE_REF_BASE]
334 }333 }
335 334
336 fn parent(&self) -> Option<&dyn Section> {335 fn parent(&self) -> Option<&dyn Section> {
gix/src/open/repository.rs+3−3
@@ -284,12 +284,12 @@ fn replacement_objects_refs_prefix( · 283 unmodified lines
284 mut filter_config_section: fn(&gix_config::file::Metadata) -> bool,284 mut filter_config_section: fn(&gix_config::file::Metadata) -> bool,
285) -> Result<Option<PathBuf>, Error> {285) -> Result<Option<PathBuf>, Error> {
286 let is_disabled = config286 let is_disabled = config
287 .boolean_filter_by_key("gitoxide.objects.noReplace", &mut filter_config_section)287 .boolean_filter_by_key("core.useReplaceRefs", &mut filter_config_section)
288 .map(|b| gitoxide::Objects::NO_REPLACE.enrich_error(b))288 .map(|b| Core::USE_REPLACE_REFS.enrich_error(b))
289 .transpose()289 .transpose()
290 .with_leniency(lenient)290 .with_leniency(lenient)
291 .map_err(config::Error::ConfigBoolean)?291 .map_err(config::Error::ConfigBoolean)?
292 .unwrap_or_default();292 .unwrap_or(true);
293 293
294 if is_disabled {294 if is_disabled {
295 return Ok(None);295 return Ok(None);
gix/tests/repository/open.rs+1−1
@@ -394,7 +394,7 @@ mod with_overrides { · 393 unmodified lines
394 for (key, expected) in [394 for (key, expected) in [
395 ("gitoxide.http.verbose", "true"),395 ("gitoxide.http.verbose", "true"),
396 ("gitoxide.allow.protocolFromUser", "file-allowed"),396 ("gitoxide.allow.protocolFromUser", "file-allowed"),
397 ("gitoxide.objects.noReplace", "no-replace"),397 ("core.useReplaceRefs", "no-replace"),
398 ("gitoxide.objects.replaceRefBase", "refs/replace-mine"),398 ("gitoxide.objects.replaceRefBase", "refs/replace-mine"),
399 ("gitoxide.committer.nameFallback", "committer name"),399 ("gitoxide.committer.nameFallback", "committer name"),
400 ("gitoxide.committer.emailFallback", "committer email"),400 ("gitoxide.committer.emailFallback", "committer email"),