https://git-scm.com/docs/git-apply says:
> When running from a subdirectory in a repository,
> patched paths outside the directory are ignored.
When we run `centpkg prep` in a dist-git repository,
patch 351 was silently skipped. When running with --verbose:
Skipped patch 'Lib/tarfile.py'.
Skipped patch 'Lib/test/recursion.tar'.
Skipped patch 'Lib/test/test_tarfile.py'.
Skipped patch 'Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst'.
This caused later patches touching the same files (e.g. 437) to not apply cleanly:
+ echo 'Patch #437 (00437-cve-2024-6232.patch):'
Patch #437 (00437-cve-2024-6232.patch):
+ /usr/bin/patch --no-backup-if-mismatch -f -p1 --fuzz=0
patching file Lib/tarfile.py
Hunk #1 succeeded at 860 (offset 14 lines).
Hunk #2 FAILED at 1374.
Hunk #3 succeeded at 1428 (offset 12 lines).
Hunk #4 succeeded at 1452 (offset 12 lines).
Hunk #5 succeeded at 1474 (offset 12 lines).
1 out of 5 hunks FAILED -- saving rejects to file Lib/tarfile.py.rej
patching file Lib/test/test_tarfile.py
Hunk #1 succeeded at 1043 (offset -3 lines).
patching file Misc/NEWS.d/next/Security/2024-07-02-13-39-20.gh-issue-121285.hrl-yI.rst
In Koji/Brew/mock patch 437 applied cleanly because builddir is not a subdirectory
of the cloned dist-git git tree and patch 351 was not skipped.
By setting $GIT_DIR we force git to ignore any git work trees in parent directories.
We set it to $PWD to make it work properly if we ever make %(auto)setup use git.
Thanks to: Florian Weimer, Lumír Balhar.