From ea636e0a92670353ac48274e704d30662f722691 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 13 Apr 2022 13:44:07 -0700 Subject: [PATCH] Write safe.directory items to system git config This is necessary for more consistent behavior across multiple distro versions. Apparently somewhere along the way, git started looking at the current user's home directory instead of $HOME. Related-Bug: https://bugs.launchpad.net/devstack/+bug/1968798 Change-Id: I941ef5ea90970a0901236afe81c551aaf24ac1d8 (cherry picked from commit 4baeb3b51fcb6196fa311f823ad3f0ac13ccf341) (cherry picked from commit 9616d22938305dd1a56067810484c15912b37d8d) (cherry picked from commit d86f23b153acc0b8d791baddf2cd90875aa0a04d) --- functions-common | 7 ++++++- unstack.sh | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/functions-common b/functions-common index fabe5fce96..491bfaed25 100644 --- a/functions-common +++ b/functions-common @@ -592,8 +592,13 @@ function git_clone { # about how we clone and work with repos. Mark them safe globally # as a work-around. # + # NOTE(danms): On bionic (and likely others) git-config may write + # ~stackuser/.gitconfig if not run with sudo -H. Using --system + # writes these changes to /etc/gitconfig which is more + # discoverable anyway. + # # [1] https://github.com/git/git/commit/8959555cee7ec045958f9b6dd62e541affb7e7d9 - sudo git config --global --add safe.directory ${git_dest} + sudo git config --system --add safe.directory ${git_dest} # print out the results so we know what change was used in the logs cd $git_dest diff --git a/unstack.sh b/unstack.sh index d9dca7c107..3e6ea349d3 100755 --- a/unstack.sh +++ b/unstack.sh @@ -185,3 +185,8 @@ fi clean_pyc_files rm -Rf $DEST/async + +# Clean any safe.directory items we wrote into the global +# gitconfig. We can identify the relevant ones by checking that they +# point to somewhere in our $DEST directory. +sudo sed -i "/directory=${DEST}/ d" /etc/gitconfig