fix: guard global git config includes with readability check for non-root containers (closes #39617)

What does this MR do?

Wraps the include.path entries for $HOME/.gitconfig and $HOME/.config/git/config in test -r guards inside setupGlobalGitConfigSeed. If the file does not exist or is not readable (e.g. owned by root in a non-root container), it is silently skipped.

Why was this MR needed?

When jobs run as non-root users inside containers, $HOME often points to a directory owned by root (e.g. /root). The runner unconditionally added include.path $HOME/.gitconfig to the seed git config, which caused git config --file ... --add include.path /root/.gitconfig to fail with Permission denied when the file wasn't readable by the job user.

What's the best way to test this MR?

Run the shells package tests: TestSetupGlobalGitConfigSeed verifies that the test -r guards are emitted before each include.path git config command, and TestSetupTokenlessGitConfig / TestWriteGetSourcesScript verify the full tokenless git config script still passes with the new guard structure.

What are the relevant issue numbers?

Closes #39617 (closed)

Edited by Ashmit Sharma

Merge request reports

Loading
Loading