Skip to content

Commit 91e6f96

Browse files
EliahKaganclaude
andcommitted
Show file ownership and safe.directory entries on every test job
Add a step to each workflow that runs the test suite that prints the ownership (NTFS Owner / POSIX uid+gid) of key paths -- the workspace, its `.git`, the gitdb and smmap submodule worktrees and gitfiles, the runner's home directory, and `~/.gitconfig` -- as well as the full list of `safe.directory` entries at that point. GitPython's tests are intentionally coupled to the layout and state of the GitPython repository they run against; ownership and the trust- config that gates whether git will operate on a path are part of that state. Surfacing them in every test job gives diagnostics to read alongside any failure that turns out to be a setup problem rather than a code defect. The step is added to: - `cygwin-test.yml`'s `test` job, with a YAML anchor (`&ownership-display`) so the temporary `reproduce-safe-dir` matrix job can reuse it via `*ownership-display`. - `pythonpackage.yml`'s `test` job (Linux/macOS/Windows-native). - `alpine-test.yml`'s `test` job. It runs after `init-tests-after-clone.sh` has populated the submodules and after `safe.directory` has been configured (in workflows that configure it), so the values reported are what the tests will see. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fec2c34 commit 91e6f96

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

.github/workflows/alpine-test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ jobs:
6161
. .venv/bin/activate
6262
pip install '.[test]'
6363
64+
- name: Show file ownership and safe.directory entries
65+
run: |
66+
echo "==================== File ownership ===================="
67+
for p in \
68+
"$(pwd)" \
69+
"$(pwd)/.git" \
70+
"$(pwd)/git/ext/gitdb" \
71+
"$(pwd)/git/ext/gitdb/.git" \
72+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap" \
73+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap/.git" \
74+
"${HOME:-}" \
75+
"${HOME:-}/.gitconfig"; do
76+
if [ -n "$p" ]; then
77+
ls -ld -- "$p" 2>/dev/null || echo "(missing: $p)"
78+
fi
79+
done
80+
echo
81+
echo "==================== safe.directory entries ===================="
82+
git config --global --get-all safe.directory 2>&1 || echo "(none)"
83+
6484
- name: Show version and platform information
6585
run: |
6686
. .venv/bin/activate

.github/workflows/cygwin-test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,65 @@ jobs:
9090
run: |
9191
pip install '.[test]'
9292
93+
- &ownership-display
94+
name: Show file ownership and safe.directory entries
95+
run: |
96+
echo "==================== File ownership (Cygwin view, ls -ld) ===================="
97+
for p in \
98+
"$(pwd)" \
99+
"$(pwd)/.git" \
100+
"$(pwd)/git/ext/gitdb" \
101+
"$(pwd)/git/ext/gitdb/.git" \
102+
"$(pwd)/.git/modules/gitdb" \
103+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap" \
104+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap/.git" \
105+
"$(pwd)/.git/modules/gitdb/modules/smmap" \
106+
"${HOME:-}" \
107+
"${HOME:-}/.gitconfig"; do
108+
if [ -n "$p" ]; then
109+
ls -ld -- "$p" 2>/dev/null || echo "(missing: $p)"
110+
fi
111+
done
112+
echo
113+
echo "==================== File ownership (Win32 view, Get-Acl) ===================="
114+
# Cygwin's ls -ld and stat go through Cygwin's SID-to-uid mapping
115+
# (well-known SIDs by their RID, machine-local accounts by 0x30000+RID).
116+
# The mapping is deterministic, but going via Win32 Get-Acl gives the
117+
# NTAccount form of the NTFS Owner SID directly, with no Cygwin layer
118+
# in between -- useful for confirming that what Cygwin reports as
119+
# "Administrators" really is the BUILTIN\Administrators SID (S-1-5-32-544)
120+
# rather than some local-machine account that Cygwin happens to map to
121+
# the same uid. The workflow sets CYGWIN_NOWINPATH=1, so Windows paths
122+
# are not on Cygwin's $PATH; invoke powershell.exe by absolute path.
123+
ps_exe=/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
124+
if [ -x "$ps_exe" ]; then
125+
for p in \
126+
"$(pwd)" \
127+
"$(pwd)/.git" \
128+
"$(pwd)/git/ext/gitdb" \
129+
"$(pwd)/git/ext/gitdb/.git" \
130+
"$(pwd)/.git/modules/gitdb" \
131+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap" \
132+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap/.git" \
133+
"$(pwd)/.git/modules/gitdb/modules/smmap" \
134+
"${HOME:-}/.gitconfig"; do
135+
if [ -n "$p" ] && [ -e "$p" ]; then
136+
wp=$(cygpath -w "$p")
137+
# Escape single-quotes for PowerShell single-quoted string literal: ' -> ''
138+
wp_escaped=${wp//\'/\'\'}
139+
owner=$("$ps_exe" -NoProfile -NonInteractive -Command \
140+
"try { (Get-Acl -LiteralPath '${wp_escaped}').Owner } catch { 'ERROR: ' + \$_.Exception.Message }" \
141+
2>/dev/null | tr -d '\r')
142+
printf " %-44s %s\n" "$owner" "$wp"
143+
fi
144+
done
145+
else
146+
echo "($ps_exe not found -- skipping Win32 view)"
147+
fi
148+
echo
149+
echo "==================== safe.directory entries ===================="
150+
git config --global --get-all safe.directory 2>&1 || echo "(none)"
151+
93152
- name: Show version and platform information
94153
run: |
95154
uname -a
@@ -192,6 +251,7 @@ jobs:
192251
- *setup-venv
193252
- *update-pypa
194253
- *install-deps
254+
- *ownership-display
195255

196256
- name: Run submodule tests
197257
run: |

.github/workflows/pythonpackage.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ jobs:
8787
run: |
8888
pip install '.[test]'
8989
90+
- name: Show file ownership and safe.directory entries
91+
run: |
92+
echo "==================== File ownership ===================="
93+
for p in \
94+
"$(pwd)" \
95+
"$(pwd)/.git" \
96+
"$(pwd)/git/ext/gitdb" \
97+
"$(pwd)/git/ext/gitdb/.git" \
98+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap" \
99+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap/.git" \
100+
"${HOME:-}" \
101+
"${HOME:-}/.gitconfig"; do
102+
if [ -n "$p" ]; then
103+
ls -ld -- "$p" 2>/dev/null || echo "(missing: $p)"
104+
fi
105+
done
106+
echo
107+
echo "==================== safe.directory entries ===================="
108+
git config --global --get-all safe.directory 2>&1 || echo "(none)"
109+
90110
- name: Show version and platform information
91111
run: |
92112
uname -a

0 commit comments

Comments
 (0)