]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Work around git safe.directory enforcement
authorSerge Hallyn <serge@hallyn.com>
Mon, 25 Apr 2022 15:42:41 +0000 (10:42 -0500)
committerSerge Hallyn <serge@hallyn.com>
Mon, 25 Apr 2022 15:52:29 +0000 (10:52 -0500)
Git wants to ensure that you do not read .git owned by other users.
But we fetch+build as 'build' user, and run tests as root user.  Those
tests calculate git topdir using git rev-parse --show-toplevel, which
git now fails.

Setting safe.directory, seems wrong.  Let's just use bash to figure
out the top dir.

tests/common/config.sh

index ea66ef3c6625616c402a6e23a276bd05febb4deb..ffd96927999b39b8589d01e622de0b170e3bd40c 100644 (file)
@@ -2,7 +2,14 @@
 
 set -e
 
-build_path=$(git rev-parse --show-toplevel)
+build_path=$(pwd)
+while [ "${build_path}" != "/" -a ! -d "${build_path}/.git" ]; do
+       build_path=$(dirname ${build_path})
+done
+if [ ! -d "${build_path}/.git" ]; then
+       echo "Not inside git directory" 1>&2
+       exit 1
+fi
 
 # Save the configuration files in tmp.
 save_config ()