Return the set of repo-root-relative paths that differ from `base`, or None if git failed (unresolvable ref, not a repo, timeout). Callers must distinguish None (error → don't trust as a filter) from set() (genuinely nothing changed). `-c core.quotePath=false -z` keeps non-ASCII and
(cwd, base, include_untracked=False)
| 301 | |
| 302 | |
| 303 | def _git_name_only(cwd, base, include_untracked=False): |
| 304 | """Return the set of repo-root-relative paths that differ from `base`, |
| 305 | or None if git failed (unresolvable ref, not a repo, timeout). Callers |
| 306 | must distinguish None (error → don't trust as a filter) from set() |
| 307 | (genuinely nothing changed). `-c core.quotePath=false -z` keeps non-ASCII |
| 308 | and space-containing paths intact.""" |
| 309 | def _run(env): |
| 310 | result = subprocess.run( |
| 311 | [*GIT_CMD, "-c", "core.quotePath=false", "diff", "--name-only", "-z", base], |
| 312 | cwd=cwd, capture_output=True, text=True, timeout=30, |
| 313 | env=env, |
| 314 | ) |
| 315 | if result.returncode != 0: |
| 316 | debug_log(f"_git_name_only({base!r}) rc={result.returncode}: {result.stderr[:200]}") |
| 317 | return None |
| 318 | return {p for p in result.stdout.split("\0") if p} |
| 319 | |
| 320 | try: |
| 321 | if not include_untracked: |
| 322 | return _run(None) |
| 323 | with _temp_index(cwd) as env: |
| 324 | return _run(env) |
| 325 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError) as e: |
| 326 | debug_log(f"_git_name_only({base!r}) error: {e}") |
| 327 | return None |
| 328 | |
| 329 | |
| 330 | def _git_status_porcelain(cwd): |
no test coverage detected