From 218f54dc28f15af8cd590071af9cf2c8dc5fc420 Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Fri, 2 Feb 2024 00:00:11 +0530 Subject: [PATCH] Fix git_ensure_safe_directory function again The command added to check whether the directory is git or not was having syntax error. Fixed the same. Also it seems adding safe-directory with local doesn't really work which actually makes sense. hence reverting to using global instead. Its still safer than before as we are not adding * and are adding the actual path of the directory --- lib/functions/general/git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/functions/general/git.sh b/lib/functions/general/git.sh index ef45c0528d..99628e89ed 100644 --- a/lib/functions/general/git.sh +++ b/lib/functions/general/git.sh @@ -55,9 +55,9 @@ function improved_git_fetch() { function git_ensure_safe_directory() { if [[ -n "$(command -v git)" ]]; then local git_dir="$1" - if regular_git -C "$1" -C rev-parse --git-dir > /dev/null 2>&1; then + if [[ -e "$1/.git" ]]; then display_alert "git: Marking all directories as safe, which should include" "$git_dir" "debug" - regular_git -C "$1" config --local --get safe.directory "$1" > /dev/null || regular_git -C "$1" config --local --add safe.directory "$1" + regular_git config --global --get safe.directory "$1" > /dev/null || regular_git config --global --add safe.directory "$1" fi else display_alert "git not installed" "a true wonder how you got this far without git - it will be installed for you" "warn"