check_no_game_data: exit 2 when git cannot list the files (CHECK-NO-GAME-DATA-GIT-ERROR) #922

Merged
TuroYT merged 2 commits from upstream-pr/922 into main 2026-11-24 20:04:57 +00:00
TuroYT commented 2026-11-24 15:12:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TuroYT on 2026-11-24T15:12:04Z.


Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135522186)

What was wrong

tracked_files in scripts/check_no_game_data.py (line 256, called from main) runs git ls-files -z with check=True and no handler. Two cases end in a traceback and exit status 1:

  • Run outside a git work tree: CalledProcessError ... status 128.
  • Run with git missing from PATH: FileNotFoundError: [Errno 2] No such file or directory: 'git'.

The docstring says exit 1 means game data was found, so a caller cannot tell the two apart. Only the unreadable-file path returns 2.

Reproduced on the branch before the change:

$ cd <empty temp dir>; python3 -I .../scripts/check_no_game_data.py
  ... subprocess.CalledProcessError: Command '['git', 'ls-files', '-z']' returned non-zero exit status 128.
rc=1
$ env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py
  ... FileNotFoundError: [Errno 2] No such file or directory: 'git'
rc=1

What changed

  • main catches OSError and CalledProcessError around the default-mode git call and returns 2.
  • It prints one line to stderr: check_no_game_data: cannot list the tracked files with git: <reason>. The reason is the first non-empty line git printed, or the OS error text.
  • The docstring documents exit 2.
  • The explicit-path mode and the normal in-repository output are unchanged.
  • tests/test_check_no_game_data.py: two tests. One empties PATH and runs in a plain folder. The other sets GIT_CEILING_DIRECTORIES and LC_ALL=C and runs in a folder outside any repository. Both expect exit 2, no stdout, one stderr line, and no traceback.

Tested

  • python3 -I tests/test_check_no_game_data.py: Ran 11 tests, OK (on the fixed code).
  • On the origin/main script: the two new tests fail (FAILED (failures=2)), so they catch the defect.
  • Normal repository output: python3 -I scripts/check_no_game_data.py > out.txt on the origin/main copy and on the fixed script gives identical bytes, exit 0 for both.
  • env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py with a file argument: exit 0 (no git call is made).
  • env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py: one line, exit 2.
  • Outside a repository: one line naming git, exit 2.
  • python3 -m compileall -q scripts tests: OK.
  • python3 -I tests/test_text_write_line_endings.py: OK, 3 tests.
  • python3 -I tests/test_no_game_data_workflow.py: OK, 3 tests.
  • python3 -I scripts/check_no_game_data.py scripts/check_no_game_data.py tests/test_check_no_game_data.py: exit 0.
  • python3 -I scripts/check_no_game_data.py over the whole tracked tree: exit 0.
  • git diff --check: clean.

Not tested: a real git failure with a multi-line message (for example, detected dubious ownership), a non-UTF-8 git message beyond a quick unit check of the helper, Windows, and macOS.

Not tested

  • Windows and macOS. The test runs only on the platform where it is executed.
  • The "game data found" exit 1 path on a repository with a real match, compared byte for byte with origin/main. The existing default-mode test covers exit 1 on the fixed code.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474864118 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/922). Originally posted by [TuroYT](https://github.com/TuroYT) on 2026-11-24T15:12:04Z. --- Claimed in the coordination issue as: CHECK-NO-GAME-DATA-GIT-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135522186) ## What was wrong `tracked_files` in `scripts/check_no_game_data.py` (line 256, called from `main`) runs `git ls-files -z` with `check=True` and no handler. Two cases end in a traceback and exit status 1: - Run outside a git work tree: `CalledProcessError ... status 128`. - Run with git missing from PATH: `FileNotFoundError: [Errno 2] No such file or directory: 'git'`. The docstring says exit 1 means game data was found, so a caller cannot tell the two apart. Only the unreadable-file path returns 2. Reproduced on the branch before the change: ``` $ cd <empty temp dir>; python3 -I .../scripts/check_no_game_data.py ... subprocess.CalledProcessError: Command '['git', 'ls-files', '-z']' returned non-zero exit status 128. rc=1 $ env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py ... FileNotFoundError: [Errno 2] No such file or directory: 'git' rc=1 ``` ## What changed - `main` catches `OSError` and `CalledProcessError` around the default-mode git call and returns 2. - It prints one line to stderr: `check_no_game_data: cannot list the tracked files with git: <reason>`. The reason is the first non-empty line git printed, or the OS error text. - The docstring documents exit 2. - The explicit-path mode and the normal in-repository output are unchanged. - `tests/test_check_no_game_data.py`: two tests. One empties PATH and runs in a plain folder. The other sets `GIT_CEILING_DIRECTORIES` and `LC_ALL=C` and runs in a folder outside any repository. Both expect exit 2, no stdout, one stderr line, and no traceback. ## Tested - `python3 -I tests/test_check_no_game_data.py`: Ran 11 tests, OK (on the fixed code). - On the origin/main script: the two new tests fail (`FAILED (failures=2)`), so they catch the defect. - Normal repository output: `python3 -I scripts/check_no_game_data.py > out.txt` on the origin/main copy and on the fixed script gives identical bytes, exit 0 for both. - `env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py` with a file argument: exit 0 (no git call is made). - `env PATH=/nonexistent /usr/bin/python3 -I scripts/check_no_game_data.py`: one line, exit 2. - Outside a repository: one line naming git, exit 2. - `python3 -m compileall -q scripts tests`: OK. - `python3 -I tests/test_text_write_line_endings.py`: OK, 3 tests. - `python3 -I tests/test_no_game_data_workflow.py`: OK, 3 tests. - `python3 -I scripts/check_no_game_data.py scripts/check_no_game_data.py tests/test_check_no_game_data.py`: exit 0. - `python3 -I scripts/check_no_game_data.py` over the whole tracked tree: exit 0. - `git diff --check`: clean. Not tested: a real git failure with a multi-line message (for example, `detected dubious ownership`), a non-UTF-8 git message beyond a quick unit check of the helper, Windows, and macOS. ## Not tested - Windows and macOS. The test runs only on the platform where it is executed. - The "game data found" exit 1 path on a repository with a real match, compared byte for byte with origin/main. The existing default-mode test covers exit 1 on the fixed code. AI-assisted (Claude Code).
kawaii-shakal commented 2026-11-24 16:14:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T16:14:03Z.


Independent test of #922 (CHECK-NO-GAME-DATA-GIT-ERROR)

Head tested: 074e53069f (merge base a2892784). Environment: Windows 11, native Python 3.13.13, Git for Windows, no GPU. This covers the Windows run that the PR lists as not tested.

Commands and results:

  • python -I -B tests/test_check_no_game_data.py: Ran 11 tests, OK.
  • python -I -B tests/test_no_game_data_workflow.py: OK.
  • Same test file with scripts/check_no_game_data.py from the merge base: both new tests FAIL (FAILED (failures=2)).
  • Mutation: narrowed the new except to subprocess.CalledProcessError only. test_git_missing_is_one_stderr_line_and_exit_2 FAILS, so the OSError branch is covered too. Restored afterwards.
  • Manual run outside any repository: python -I scripts/check_no_game_data.py prints one line, check_no_game_data: cannot list the tracked files with git: fatal: not a git repository (or any of the parent directories): .git, and exits 2.
  • Manual run inside the worktree over the whole tracked tree: exit 0.
  • git merge-tree --write-tree origin/main <head> (origin/main 0af7753c): clean.
  • python -I scripts/check_no_game_data.py on the changed files: exit 0. git diff --check: clean.

Findings:

  • scripts/check_no_game_data.py:296-304: only the default (git) mode changes, and explicit paths never call git. tracked_files already uses capture_output=True (line 257), so git's message lands in e.stderr and is not also printed raw. That is why the output is exactly one line.
  • The only caller in the repository, .github/workflows/no-game-data.yml:35, treats any non-zero code as a failure, so exit 2 changes nothing there.
  • Minor, not blocking: the outside-repository test asserts the English not a git repository text via LC_ALL=C, which is fine on Windows and Linux. However, a GIT_DIR or GIT_WORK_TREE already set in the caller's environment would let git find a repository. Popping those from env would make the test fully hermetic.

Verdict: looks good.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137332380 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7137332380). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-24T16:14:03Z. --- Independent test of #922 (CHECK-NO-GAME-DATA-GIT-ERROR) Head tested: 074e53069faa592b9fcabc47f128a383dcdc0f82 (merge base a2892784). Environment: Windows 11, native Python 3.13.13, Git for Windows, no GPU. This covers the Windows run that the PR lists as not tested. Commands and results: - `python -I -B tests/test_check_no_game_data.py`: Ran 11 tests, OK. - `python -I -B tests/test_no_game_data_workflow.py`: OK. - Same test file with `scripts/check_no_game_data.py` from the merge base: both new tests FAIL (`FAILED (failures=2)`). - Mutation: narrowed the new `except` to `subprocess.CalledProcessError` only. `test_git_missing_is_one_stderr_line_and_exit_2` FAILS, so the `OSError` branch is covered too. Restored afterwards. - Manual run outside any repository: `python -I scripts/check_no_game_data.py` prints one line, `check_no_game_data: cannot list the tracked files with git: fatal: not a git repository (or any of the parent directories): .git`, and exits 2. - Manual run inside the worktree over the whole tracked tree: exit 0. - `git merge-tree --write-tree origin/main <head>` (origin/main 0af7753c): clean. - `python -I scripts/check_no_game_data.py` on the changed files: exit 0. `git diff --check`: clean. Findings: - scripts/check_no_game_data.py:296-304: only the default (git) mode changes, and explicit paths never call git. `tracked_files` already uses `capture_output=True` (line 257), so git's message lands in `e.stderr` and is not also printed raw. That is why the output is exactly one line. - The only caller in the repository, `.github/workflows/no-game-data.yml:35`, treats any non-zero code as a failure, so exit 2 changes nothing there. - Minor, not blocking: the outside-repository test asserts the English `not a git repository` text via `LC_ALL=C`, which is fine on Windows and Linux. However, a `GIT_DIR` or `GIT_WORK_TREE` already set in the caller's environment would let git find a repository. Popping those from `env` would make the test fully hermetic. Verdict: looks good. AI-assisted.
TuroYT commented 2026-11-24 17:05:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TuroYT on 2026-11-24T17:05:19Z.


Thanks for the Windows run and the mutation check.

Pushed ec0d003e5: test_outside_a_repository_is_one_stderr_line_and_exit_2 now builds its environment without GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE. The test file passes (11 tests) with and without GIT_DIR set in the caller's environment.

Setting GIT_DIR also showed that the tests that create their own repositories (git add in a temporary directory) are not hermetic either: with GIT_DIR exported, they stage files into the repository that GIT_DIR points at. That is older than this PR and I left it alone here.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138665776 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7138665776). Originally posted by [TuroYT](https://github.com/TuroYT) on 2026-11-24T17:05:19Z. --- Thanks for the Windows run and the mutation check. Pushed ec0d003e5: `test_outside_a_repository_is_one_stderr_line_and_exit_2` now builds its environment without `GIT_DIR`, `GIT_WORK_TREE` and `GIT_INDEX_FILE`. The test file passes (11 tests) with and without `GIT_DIR` set in the caller's environment. Setting `GIT_DIR` also showed that the tests that create their own repositories (`git add` in a temporary directory) are not hermetic either: with `GIT_DIR` exported, they stage files into the repository that `GIT_DIR` points at. That is older than this PR and I left it alone here.
MoonEyes commented 2026-11-24 17:39:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-24T17:39:37Z.

Review: APPROVED


LGTM. Measured on Windows 11 (French locale), Python 3.14, against main cf4c00cba:

  • python -I tests/test_check_no_game_data.py: main Ran 9, OK; this PR and a local merge into main Ran 11, OK. With main's script, both new tests fail.
  • Outside a repository (GIT_CEILING_DIRECTORIES set), main prints a traceback and exits 1, and this PR prints one line and exits 2. The same holds with git removed from PATH.
  • On a French Windows, the git-missing line carries the OS error text (e.strerror), so it is localized. It is still one line with exit 2, which is all the test checks.

AI-assisted: yes (Claude Code ran the checks; I read them).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6044346114 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/922#pullrequestreview-6044346114). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-24T17:39:37Z. **Review:** APPROVED --- LGTM. Measured on Windows 11 (French locale), Python 3.14, against main cf4c00cba: - `python -I tests/test_check_no_game_data.py`: main `Ran 9, OK`; this PR and a local merge into main `Ran 11, OK`. With main's script, both new tests fail. - Outside a repository (`GIT_CEILING_DIRECTORIES` set), main prints a traceback and exits 1, and this PR prints one line and exits 2. The same holds with git removed from PATH. - On a French Windows, the git-missing line carries the OS error text (`e.strerror`), so it is localized. It is still one line with exit 2, which is all the test checks. AI-assisted: yes (Claude Code ran the checks; I read them).
QemmHD commented 2026-11-24 20:04:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T20:04:55Z.


Merging.

Why merged: CHECK-NO-GAME-DATA-GIT-ERROR: check_no_game_data exits 2 with one stderr line when git can't list the tracked files. Exit 1 still means game data was found, so a broken git can no longer look like a clean scan or a hit. The scan logic itself is unchanged. kawaii-shakal checked it, and MoonEyes approved after the follow-up push, which only clears GIT_DIR in a test.

Why it's good: Own tests: 11 passed. The consistency set with its 2 new tests: 573 passed.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143014439 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/922#issuecomment-7143014439). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T20:04:55Z. --- Merging. **Why merged:** CHECK-NO-GAME-DATA-GIT-ERROR: check_no_game_data exits 2 with one stderr line when git can't list the tracked files. Exit 1 still means game data was found, so a broken git can no longer look like a clean scan or a hit. The scan logic itself is unchanged. kawaii-shakal checked it, and MoonEyes approved after the follow-up push, which only clears GIT_DIR in a test. **Why it's good:** Own tests: 11 passed. The consistency set with its 2 new tests: 573 passed. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!922
No description provided.