Null the default excludes and attributes files for scratch repos

improvise-vwjj, found reviewing #248. GIT_CONFIG_GLOBAL=/dev/null empties
the config files. It does not stop git falling back to
$XDG_CONFIG_HOME/git/ignore (or ~/.config/git/ignore) when
core.excludesFile is unset, and git/attributes has the same kind of
default. So a *.gz line in the user's default ignore file still failed
a_gzipped_document_is_walked.

run_git now passes -c core.excludesFile=/dev/null and
-c core.attributesFile=/dev/null. A -c argument outranks every config
file and every default path.

The new test re-runs the gzip shape test under an XDG_CONFIG_HOME whose
git/ignore holds *.gz, and again with a git/attributes line that breaks
git add. Each half was red on its own.

Stacked on #248 (fix/53zz-scratch-repo-env).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Edward Langley
2026-09-23 11:29:01 -07:00
parent f5cfc7edd3
commit 56ac72a291
2 changed files with 62 additions and 0 deletions
+37
View File
@@ -545,6 +545,43 @@ Rivals:
- Drop `GIT_CONFIG_NOSYSTEM=1`: red, in the system run. The system scope is
there so that this half of the fix has a witness at all.
### a_scratch_repo_ignores_the_users_default_ignore_and_attributes_files
improvise-vwjj, found reviewing PR #248 at `f5cfc7ed`. The test above sets
`core.excludesFile` *inside* a config file, so emptying the config files looks
like a complete fix. It is not. When `core.excludesFile` is unset, git falls
back to `$XDG_CONFIG_HOME/git/ignore`, or `~/.config/git/ignore` when
`XDG_CONFIG_HOME` is unset. No config file is involved, so
`GIT_CONFIG_GLOBAL=/dev/null` leaves the fallback in force. It is also the
commonest place to keep a global ignore, because it needs no config line.
`core.attributesFile` has the same kind of default, `git/attributes`.
The test points `XDG_CONFIG_HOME` at a temp directory and re-runs the gzip
shape test in a child twice:
- once with `git/ignore` holding `*.gz`;
- once with `git/attributes` holding `*.gz working-tree-encoding=UTF-16`.
The attributes line is chosen because it breaks `git add`: the one-byte file
cannot be decoded as UTF-16. An attribute that only changes line endings would
leave the add succeeding, and the case would witness nothing.
Before the fix (at `f5cfc7ed`) the ignore run failed at `git add`. With only
`-c core.excludesFile=/dev/null` added, the attributes run failed. So each half
of the fix is witnessed separately.
The fix is two `-c` arguments in `run_git`: `core.excludesFile=/dev/null` and
`core.attributesFile=/dev/null`. A `-c` argument outranks every config file and
every default path, so the `~/.config` fallback is closed by the same two lines.
This test sets only `XDG_CONFIG_HOME`, so the `~/.config` path is covered by
that argument, not exercised.
Rivals, each run against the fixed file:
- Drop `core.excludesFile=/dev/null`: red, `fails under a default git/ignore`.
- Drop `core.attributesFile=/dev/null`: red, `fails under a default
git/attributes`.
---
## `tests/web_demo_model.rs`
+25
View File
@@ -74,6 +74,8 @@ fn run_git(root: &Path, args: &[&str]) {
let status = git(root)
.env("GIT_CONFIG_GLOBAL", "/dev/null")
.env("GIT_CONFIG_NOSYSTEM", "1")
.args(["-c", "core.excludesFile=/dev/null"])
.args(["-c", "core.attributesFile=/dev/null"])
.args(args)
.status()
.expect("git runs");
@@ -216,3 +218,26 @@ fn a_scratch_repo_ignores_the_users_global_and_system_excludes() {
);
}
}
/// improvise-vwjj: git's DEFAULT ignore and attributes files need no config line.
/// Evidence: `context/test-evidence/tui.md`.
#[test]
fn a_scratch_repo_ignores_the_users_default_ignore_and_attributes_files() {
let files = [
("ignore", "*.gz\n"),
("attributes", "*.gz working-tree-encoding=UTF-16\n"),
];
for (name, text) in files {
let xdg = tempfile::tempdir().expect("a temp dir");
write(xdg.path(), &format!("git/{name}"), text);
let out = rerun_with_env(
"a_gzipped_document_is_walked",
&[("XDG_CONFIG_HOME", xdg.path())],
);
assert!(
out.status.success(),
"the gzip shape test fails under a default git/{name}: {}",
String::from_utf8_lossy(&out.stdout)
);
}
}