The shipped-document walk strips every GIT_TRACE* variable (improvise-2iws)
GIT_TRACE, GIT_TRACE2_EVENT and GIT_TRACE_PERFORMANCE are process-wide, so --local-env-vars lists none of them. Pointed at /dev/stdout, git wrote trace lines into the ls-files -z output, and the walk read them as paths. git() now builds on untraced_git(), which removes every variable starting with GIT_TRACE: a prefix, because the family is open-ended. The rev-parse --local-env-vars call goes through it too, since its stdout is parsed as well. the_walk_ignores_a_git_trace_sent_to_stdout reruns the gzip shape test and every_shipped_document_loads in children with all three set to /dev/stdout. It failed at #269's head. Rivals, each of which fails it: - no strip; - the exact name only; - keep GIT_TRACE_PERFORMANCE; - keep GIT_TRACE2_EVENT. 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:
@@ -60,11 +60,11 @@ const PATHSPEC_AND_ATTRIBUTE_SETTINGS: [&str; 5] = [
|
||||
/// `git -C root`, with every repo-local variable a caller exported removed,
|
||||
/// since `GIT_DIR` and friends override `-C` (improvise-53zz).
|
||||
fn git(root: &Path) -> std::process::Command {
|
||||
let names = std::process::Command::new("git")
|
||||
let names = untraced_git()
|
||||
.args(["rev-parse", "--local-env-vars"])
|
||||
.output()
|
||||
.expect("git runs");
|
||||
let mut git = std::process::Command::new("git");
|
||||
let mut git = untraced_git();
|
||||
for name in String::from_utf8(names.stdout).expect("UTF-8").lines() {
|
||||
git.env_remove(name);
|
||||
}
|
||||
@@ -76,6 +76,18 @@ fn git(root: &Path) -> std::process::Command {
|
||||
git
|
||||
}
|
||||
|
||||
/// `git` with every `GIT_TRACE*` variable removed: one pointed at stdout writes
|
||||
/// into what we parse. A prefix, since the family is open-ended (improvise-2iws).
|
||||
fn untraced_git() -> std::process::Command {
|
||||
let mut git = std::process::Command::new("git");
|
||||
for (name, _) in std::env::vars_os() {
|
||||
if name.to_string_lossy().starts_with("GIT_TRACE") {
|
||||
git.env_remove(name);
|
||||
}
|
||||
}
|
||||
git
|
||||
}
|
||||
|
||||
/// A scratch repository, so each way of shipping a document is set up for real.
|
||||
fn scratch_repo() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().expect("a temp dir");
|
||||
@@ -305,3 +317,28 @@ fn the_walk_ignores_the_users_pathspec_and_attribute_settings() {
|
||||
}
|
||||
assert!(failed.is_empty(), "{}", failed.join("\n"));
|
||||
}
|
||||
|
||||
/// improvise-2iws: a git trace sent to stdout lands in `ls-files -z`'s output
|
||||
/// and is read as paths. Evidence: `context/test-evidence/tui.md`.
|
||||
#[test]
|
||||
fn the_walk_ignores_a_git_trace_sent_to_stdout() {
|
||||
// All three at once, one child per test: each alone breaks the walk, and a
|
||||
// strip of one exact name leaves the other two (the prefix is the point).
|
||||
let stdout = Path::new("/dev/stdout");
|
||||
let traces = [
|
||||
("GIT_TRACE", stdout),
|
||||
("GIT_TRACE2_EVENT", stdout),
|
||||
("GIT_TRACE_PERFORMANCE", stdout),
|
||||
];
|
||||
for test in [
|
||||
"a_gzipped_document_is_walked",
|
||||
"every_shipped_document_loads",
|
||||
] {
|
||||
let out = rerun_with_env(test, &traces);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{test} under a trace to stdout: {}",
|
||||
told(&out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user