diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-18 12:39:26 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-18 12:39:26 +0800 |
| commit | cc2d262b1d47748e92d436933509d7f5b78c2414 (patch) | |
| tree | 13f01b67031ef5bcddc0727258688f24a3e1efdf /mingling_ci/src/git.rs | |
| parent | 467443d37191c79e8ab7700e2d8d7e4e6666f9e5 (diff) | |
fix: use porcelain diff for worktree cleanliness check
Switch from `git diff-index --quiet` to `git diff --quiet` to
refresh the index first, avoiding false change reports from
stale stat records after compilation.
Diffstat (limited to 'mingling_ci/src/git.rs')
| -rw-r--r-- | mingling_ci/src/git.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mingling_ci/src/git.rs b/mingling_ci/src/git.rs index 3d1404b..a6fab2c 100644 --- a/mingling_ci/src/git.rs +++ b/mingling_ci/src/git.rs @@ -42,12 +42,19 @@ where } } -/// Returns `true` when `git diff-index --quiet HEAD --` succeeds, i.e. the -/// working tree has no tracked changes. Git failures count as "not clean" so -/// the caller falls back to the marker-file path. +/// Returns `true` when the working tree has no tracked changes relative to +/// HEAD. Git failures count as "not clean" so the caller falls back to the +/// marker-file path. +/// +/// Uses the porcelain `git diff --quiet HEAD` rather than the plumbing +/// `git diff-index --quiet HEAD`: after a full compile the source files' +/// mtimes can be newer than the index stat records even though their content +/// is unchanged, and `diff-index` reports that stale stat as a change. The +/// porcelain diff refreshes the index first (via `diff.autoRefreshIndex`), +/// so it only reports real content differences. pub(crate) fn worktree_clean() -> bool { Command::new("git") - .args(["diff-index", "--quiet", "HEAD", "--"]) + .args(["diff", "--quiet", "HEAD", "--"]) .status() .is_ok_and(|status| status.success()) } |
