Skip to content

Commit 5272f31

Browse files
EliahKaganclaude
andcommitted
diag: token-state and file-creation tests across PowerShell/Cygwin
Investigational workflow that replaces the test matrix with a single diag-token job to isolate why the outer git clone produces Administrators-owned dirs while subsequent submodule operations under the same runneradmin account produce runneradmin-owned dirs. The job runs both PowerShell-side and Cygwin-side tests: - whoami /all from each side (token state) - NoDefaultAdminOwner registry check - A: PowerShell New-Item directory - B: PowerShell-spawned git init - C: cmd.exe-spawned mkdir - D: Cygwin mkdir - E: Cygwin-spawned (Cygwin) git init - F: Cygwin-spawned Git for Windows git init - G: Cygwin-spawned PowerShell New-Item Each test reports the NTFS Owner of the resulting directory (via Get-Acl on the PowerShell side, stat -c '%U(%u)' on the Cygwin side) so we can see which code paths produce BUILTIN\Administrators ownership versus runneradmin ownership. This branch (claude/cygwin-diag-token) is for investigation only and is not part of the fix chain. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3b26603 commit 5272f31

1 file changed

Lines changed: 86 additions & 109 deletions

File tree

.github/workflows/cygwin-test.yml

Lines changed: 86 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,131 +6,108 @@ permissions:
66
contents: read
77

88
jobs:
9-
test:
10-
strategy:
11-
matrix:
12-
selection: [fast, perf]
13-
include:
14-
- selection: fast
15-
additional-pytest-args: --ignore=test/performance
16-
- selection: perf
17-
additional-pytest-args: test/performance
18-
19-
fail-fast: false
20-
9+
diag-token:
2110
runs-on: windows-latest
2211

23-
env: &cygwin-env
12+
env:
2413
CHERE_INVOKING: "1"
2514
CYGWIN_NOWINPATH: "1"
2615

27-
defaults: &cygwin-defaults
16+
defaults:
2817
run:
2918
shell: C:\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr "{0}"
3019

3120
steps:
32-
- &force-lf
33-
name: Force LF line endings
21+
- name: Force LF line endings
3422
run: |
35-
git config --global core.autocrlf false # Affects the non-Cygwin git.
36-
shell: pwsh # Do this outside Cygwin, to affect actions/checkout.
23+
git config --global core.autocrlf false
24+
shell: pwsh
3725

38-
- &checkout
39-
uses: actions/checkout@v6
26+
- uses: actions/checkout@v6
4027
with:
4128
fetch-depth: 0
4229

43-
- &install-cygwin
44-
name: Install Cygwin
30+
- name: Install Cygwin
4531
uses: cygwin/cygwin-install-action@v6
4632
with:
47-
packages: git python39 python-pip-wheel python-setuptools-wheel python-wheel-wheel
48-
add-to-path: false # No need to change $PATH outside the Cygwin environment.
49-
50-
- &verbose-output
51-
name: Arrange for verbose output
52-
run: |
53-
# Arrange for verbose output but without shell environment setup details.
54-
echo 'set -x' >~/.bash_profile
55-
56-
- &safe-directory
57-
name: Special configuration for Cygwin git
58-
run: |
59-
git config --global --add safe.directory "$(pwd)"
60-
git config --global --add safe.directory "$(pwd)/.git"
61-
git config --global --add safe.directory "$(pwd)/git/ext/gitdb"
62-
git config --global --add safe.directory "$(pwd)/git/ext/gitdb/gitdb/ext/smmap"
63-
git config --global core.autocrlf false
64-
65-
- &prepare-repo
66-
name: Prepare this repo for tests
67-
run: |
68-
./init-tests-after-clone.sh
69-
70-
- &git-identity
71-
name: Set git user identity and command aliases for the tests
72-
run: |
73-
git config --global user.email "travis@ci.com"
74-
git config --global user.name "Travis Runner"
75-
# If we rewrite the user's config by accident, we will mess it up
76-
# and cause subsequent tests to fail
77-
cat test/fixtures/.gitconfig >> ~/.gitconfig
78-
79-
- &setup-venv
80-
name: Set up virtual environment
81-
run: |
82-
python3.9 -m venv .venv
83-
echo 'BASH_ENV=.venv/bin/activate' >>"$GITHUB_ENV"
33+
packages: git
34+
add-to-path: false
8435

85-
- &update-pypa
86-
name: Update PyPA packages
36+
- name: PowerShell-side token state and file-creation tests
37+
shell: pwsh
8738
run: |
88-
python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
89-
90-
- &install-deps
91-
name: Install project and test dependencies
92-
run: |
93-
pip install '.[test]'
94-
95-
- name: Show version and platform information
96-
run: |
97-
uname -a
98-
command -v git python
99-
git version
100-
python --version
101-
python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'
102-
103-
- name: Test with pytest (${{ matrix.additional-pytest-args }})
104-
run: |
105-
pytest --color=yes -p no:sugar --instafail -vv ${{ matrix.additional-pytest-args }}
106-
107-
reproduce-safe-dir:
108-
strategy:
109-
matrix:
110-
run: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256]
111-
fail-fast: false
112-
113-
runs-on: windows-latest
114-
115-
env: *cygwin-env
116-
117-
defaults: *cygwin-defaults
118-
119-
steps:
120-
- *force-lf
121-
- *checkout
122-
- *install-cygwin
123-
- *verbose-output
124-
- *safe-directory
125-
- *prepare-repo
126-
- *git-identity
127-
- *setup-venv
128-
- *update-pypa
129-
- *install-deps
130-
131-
- name: Run submodule tests
39+
$repo = "D:\a\GitPython\GitPython"
40+
Write-Host "==================== whoami /all (PowerShell) ===================="
41+
whoami /all
42+
Write-Host ""
43+
Write-Host "==================== System policy: NoDefaultAdminOwner ===================="
44+
try {
45+
$val = (Get-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Lsa' -Name NoDefaultAdminOwner -ErrorAction Stop).NoDefaultAdminOwner
46+
Write-Host "NoDefaultAdminOwner = $val (0=Admin-owner, 1=Object-creator)"
47+
} catch {
48+
Write-Host "NoDefaultAdminOwner not set (default applies)"
49+
}
50+
Write-Host ""
51+
Write-Host "==================== Test A: PowerShell New-Item directory ===================="
52+
$td = "$repo\test-pwsh-mkdir"
53+
New-Item -ItemType Directory -Path $td -Force | Out-Null
54+
$acl = Get-Acl -LiteralPath $td
55+
Write-Host "Owner of $td : $($acl.Owner)"
56+
Remove-Item $td -Force
57+
Write-Host ""
58+
Write-Host "==================== Test B: PowerShell-spawned git init ===================="
59+
$td2 = "$repo\test-pwsh-gitinit"
60+
New-Item -ItemType Directory -Path $td2 -Force | Out-Null
61+
Push-Location $td2
62+
& "C:\Program Files\Git\bin\git.exe" init 2>&1 | Out-Null
63+
Pop-Location
64+
$acl1 = Get-Acl -LiteralPath $td2
65+
$acl2 = Get-Acl -LiteralPath "$td2\.git"
66+
Write-Host "Owner of $td2 (PowerShell-created) : $($acl1.Owner)"
67+
Write-Host "Owner of $td2\.git (git-init-created) : $($acl2.Owner)"
68+
Remove-Item $td2 -Recurse -Force
69+
Write-Host ""
70+
Write-Host "==================== Test C: cmd.exe-spawned mkdir ===================="
71+
$td3 = "$repo\test-cmd-mkdir"
72+
cmd.exe /c "mkdir `"$td3`""
73+
$acl = Get-Acl -LiteralPath $td3
74+
Write-Host "Owner of $td3 : $($acl.Owner)"
75+
Remove-Item $td3 -Force
76+
77+
- name: Cygwin-side token state and file-creation tests
13278
run: |
133-
python -m pytest -vv \
134-
test/test_docs.py::Tutorials::test_submodules \
135-
test/test_repo.py::TestRepo::test_submodules \
136-
test/test_submodule.py::TestSubmodule::test_root_module
79+
set +e
80+
echo "==================== id (Cygwin) ===================="
81+
id
82+
echo
83+
echo "==================== whoami /all (called from Cygwin) ===================="
84+
/cygdrive/c/Windows/System32/whoami.exe /all 2>&1 | head -50
85+
echo
86+
echo "==================== Test D: Cygwin mkdir ===================="
87+
td="$(pwd)/test-cygwin-mkdir"
88+
mkdir "$td"
89+
echo "Owner: $(stat -c '%U(%u)' "$td")"
90+
rmdir "$td"
91+
echo
92+
echo "==================== Test E: Cygwin-spawned git init ===================="
93+
td2="$(pwd)/test-cygwin-gitinit"
94+
mkdir "$td2"
95+
( cd "$td2" && git init -q )
96+
echo "Owner of $td2 (Cygwin-mkdir): $(stat -c '%U(%u)' "$td2")"
97+
echo "Owner of $td2/.git (cygwin-git): $(stat -c '%U(%u)' "$td2/.git")"
98+
rm -rf "$td2"
99+
echo
100+
echo "==================== Test F: Cygwin-spawned Windows git init ===================="
101+
td3="$(pwd)/test-cygwin-spawns-wingit"
102+
mkdir "$td3"
103+
( cd "$td3" && /cygdrive/c/Program\ Files/Git/bin/git.exe init -q )
104+
echo "Owner of $td3 (Cygwin-mkdir): $(stat -c '%U(%u)' "$td3")"
105+
echo "Owner of $td3/.git (Cygwin->WinGit): $(stat -c '%U(%u)' "$td3/.git")"
106+
rm -rf "$td3"
107+
echo
108+
echo "==================== Test G: Cygwin-spawned PowerShell mkdir ===================="
109+
td4="$(pwd)/test-cygwin-spawns-pwsh"
110+
powershell.exe -Command "New-Item -ItemType Directory -Path '$(cygpath -w "$td4")' -Force" | head -2
111+
echo "Owner: $(stat -c '%U(%u)' "$td4")"
112+
rm -rf "$td4"
113+
true

0 commit comments

Comments
 (0)