Skip to content

Commit 8d68ed4

Browse files
committed
Auto merge of #13920 - weihanglo:git-safe-directory, r=ehuss
test: set safe.directory for git repo in apache container ### What does this PR try to resolve? Failure in container tests due to a new version of `git` package in Alpine Linux Package repository. See also <#13913 (comment)> ### How should we test and review this PR? Alpine Linux Package repository 3.19 just bumped git package to 2.43.4 from 2.43.0. The docker image `httpd:2.4-alpine` we use in container tests failed due to the git version bump. The `httpd` log shown that ``` 240.10.0.1 - - [16/May/2024:03:52:36 +0000] "GET /repos/bar.git/info/refs?service=git-upload-pack HTTP/1.1" 500 - [16/May/2024:03:52:36 +0000] 240.10.0.1 TLSv1.3 TLS_AES_256_GCM_SHA384 "GET /repos/bar.git/info/refs?service=git-upload-pack HTTP/1.1" - fatal: detected dubious ownership in repository at '/repos/bar.git' To add an exception for this directory, call: git config --global --add safe.directory /repos/bar.git ``` git/git@f4aa8c8 is likely the commit causing problems. So I ended up adding `git config --system --add safe.directory '*'` to the Dockerfile of apache container. Note that we need `--system` instead of `--global` because `httpd` are running under the other user www-data, not root.
2 parents fc13634 + 2fd4b44 commit 8d68ed4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

crates/cargo-test-support/containers/apache/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ COPY bar /repos/bar
66
WORKDIR /repos/bar
77
RUN git config --global user.email "testuser@example.com" &&\
88
git config --global user.name "Test User" &&\
9+
git config --system --add safe.directory '*' &&\
910
git init -b master . &&\
1011
git add Cargo.toml src &&\
1112
git commit -m "Initial commit" &&\
12-
mv .git ../bar.git &&\
13-
cd ../bar.git &&\
14-
git config --bool core.bare true &&\
15-
rm -rf ../bar
13+
cd .. &&\
14+
git clone --bare bar bar.git &&\
15+
rm -rf bar
1616
WORKDIR /
1717

1818
EXPOSE 443

crates/cargo-test-support/containers/sshd/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ RUN git config --global user.email "testuser@example.com" &&\
1717
git init -b master . &&\
1818
git add Cargo.toml src &&\
1919
git commit -m "Initial commit" &&\
20-
mv .git ../bar.git &&\
21-
cd ../bar.git &&\
22-
git config --bool core.bare true &&\
23-
rm -rf ../bar
20+
cd .. &&\
21+
git clone --bare bar bar.git &&\
22+
rm -rf bar
2423
WORKDIR /
2524
USER root
2625

0 commit comments

Comments
 (0)