From 5e60638eccaf11f91ece8670b7f0139c33b7e6a3 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Fri, 25 May 2018 11:42:28 +0200
Subject: [PATCH] Changed filters to be global

---
 kicad-git-setup | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/kicad-git-setup b/kicad-git-setup
index bc34e0f..4aef1bd 100755
--- a/kicad-git-setup
+++ b/kicad-git-setup
@@ -48,13 +48,27 @@ done
 FILTER=( "filter.kicad_pro.clean sed -E 's/^update=.*$/update=Date/'" )
 FILTER+=( "filter.kicad_pro.smudge cat" )
 FILTER+=( "filter.kicad_sch.clean sed -E 's/#(PWR|FLG)[0-9]+/#\1?/'" )
-FILTER+=( "filter.kicad_sch.smudge cat" )
+FILTER+=( "filter.kicad_sch.smudge cata" )
 for f in "${FILTER[@]}" ; do
     if [[ "$f" =~ ([^\ ]+)[\ ]+(.*) ]] ; then
          KEY=${BASH_REMATCH[1]}
          VALUE=${BASH_REMATCH[2]}
-         if ! git config --get "${KEY}" > /dev/null ; then
-              git config "${KEY}" "${VALUE}"
+         CURRENT_GLOBAL=$(git config --global --get "${KEY}")
+         CURRENT_LOCAL=$(git config --local --get "${KEY}")
+         if [ -z "${CURRENT_GLOBAL}" -a -z "${CURRENT_LOCAL}" ] ; then
+             git config --global "${KEY}" "${VALUE}"
+         elif [ -n "${CURRENT_LOCAL}" ] ; then
+             echo "You need to do 'git config --local --unset ${KEY}'" >&2
+         elif [ "${CURRENT_GLOBAL}" != "${VALUE}" ] ; then
+             cat <<EOF >&2
+Current '${KEY}' is 
+  '${CURRENT_GLOBAL}'
+expected
+  '${VALUE}'
+do 
+  git config --global --unset ${KEY} 
+  $0 $@
+EOF
          fi
     fi
 done
-- 
GitLab