[asterisk-scf-commits] asterisk-scf/integration/gitall.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Apr 15 10:05:58 CDT 2011


branch "master" has been updated
       via  d33a2d15a138916e68c04da9c636b0a7c0ff8731 (commit)
      from  f3a8a9d6ec7d8dc25d17fb46897fcb09a192211f (commit)

Summary of changes:
 gitall-asterisk-scf.sh |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit d33a2d15a138916e68c04da9c636b0a7c0ff8731
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Apr 15 10:05:08 2011 -0500

    Remove usage of --work-tree, because various versions of git interpret it
    differently. Instead, go back to changing directories to run git, but do it
    in a way that doesn't require a subshell.

diff --git a/gitall-asterisk-scf.sh b/gitall-asterisk-scf.sh
index 2cb747a..4d7dc97 100755
--- a/gitall-asterisk-scf.sh
+++ b/gitall-asterisk-scf.sh
@@ -62,6 +62,15 @@ function collapse()
     echo "${head}"
 }
 
+# run git in the directory specified by the first argument
+function git_in_dir()
+{
+    pushd ${1} > /dev/null
+    shift
+    git "$@"
+    popd > /dev/null
+}
+
 gitdepot_pull=`git config --get remote.origin.url | sed "s at asterisk-scf/integration/gitall.*@@"`
 gitdepot_push=`git config --get remote.origin.pushurl | sed "s at asterisk-scf/integration/gitall.*@@"`
 gitdepot_push=${gitdepot_push:-${gitdepot_pull}}
@@ -177,18 +186,18 @@ EOF
 
             if [ -d ${repoDir}/.git ]; then
                 # update the origin to what is specified in repoUri
-                git --git-dir=${repoDir}/.git remote set-url origin ${repoUri}
+                git_in_dir ${repoDir} remote set-url origin ${repoUri}
                 if test ${gitdepot_push}; then
-                    git --git-dir=${repoDir}/.git remote set-url --push origin ${repoPushUri}
+                    git_in_dir ${repoDir} remote set-url --push origin ${repoPushUri}
                 else
 		    # we really should use 'git remote set-url --delete' here, but coming up
 		    # with the proper regex syntax for the URL to be match seems to be difficult
-                    git --git-dir=${repoDir}/.git config --unset remote.origin.pushurl
+                    git_in_dir ${repoDir} config --unset remote.origin.pushurl
                 fi
-                if git --git-dir=${repoDir}/.git rev-parse --verify @{upstream} > /dev/null 2>&1; then
-                    upstream=$(git --git-dir=${repoDir}/.git for-each-ref --format="%(upstream:short)" $(git --git-dir=${repoDir}/.git rev-parse --symbolic-full-name HEAD))
+                if git_in_dir ${repoDir} rev-parse --verify @{upstream} > /dev/null 2>&1; then
+                    upstream=$(git_in_dir ${repoDir} for-each-ref --format="%(upstream:short)" $(git_in_dir ${repoDir} rev-parse --symbolic-full-name HEAD))
                     echo ">> Pulling from ${upstream} (${repoDir})"
-                    git --git-dir=${repoDir}/.git --work-tree=.. pull
+                    git_in_dir ${repoDir} pull
                 else
                     echo "-- Skipping ${repoDir}; no upstream branch"
                 fi
@@ -219,13 +228,13 @@ function passthrough()
                 echo "!! Repo ${repoName} not yet cloned" >&2
                 exit 1
             fi
-	    originRepo=$(basename "$(git --git-dir=${repoDir}/.git config --get remote.origin.url)")
+	    originRepo=$(basename "$(git_in_dir ${repoDir} config --get remote.origin.url)")
 	    local -a replace_repo=(${@/REPO/${originRepo}})
 	    local -a replace_pull=(${replace_repo[@]/PULL/${gitdepot_pull}})
 	    local -a replace_push=(${replace_pull[@]/PUSH/${gitdepot_push}})
 	    local -a gitargs=(${replace_push[@]})
             echo ">> git" "${gitargs[@]}" "(${repoName})"
-            git --git-dir=${repoDir}/.git --work-tree=.. "${gitargs[@]}"
+            git_in_dir ${repoDir} "${gitargs[@]}"
             if test $? -ne 0; then
                 echo >&2
                 echo "!! Failed to '$1' ${repoName}." >&2
@@ -245,7 +254,7 @@ function dry_run()
             echo "!! Repo ${repoName} not yet cloned" >&2
             exit 1
         fi
-        git --git-dir=${RepoDir}/.git --work-tree=.. s"$@" --dry-run --quiet
+        git_in_dir ${repoDir} "$@" --dry-run --quiet
         if test $? -ne 0; then
             echo >&2
             echo "!! Would fail to '$1' ${repoName}." >&2
@@ -259,7 +268,7 @@ function dry_run()
             repoDir=$(basename ${repo})
             repoName=$(basename "$(cd ${repoDir} && pwd)")
             echo ">> git" "$@" "(${repoName})"
-            git --git-dir=${RepoDir}/.git --work-tree=.. "$@"
+            git_in_dir ${repoDir} "$@"
             if test $? -ne 0; then
                 echo "!! Failed to 'push' ${repoName}." >&2
                 exit 1

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/gitall.git



More information about the asterisk-scf-commits mailing list