]> git.phdru.name Git - git-scripts.git/blobdiff - pull-usrlocalsrc
Feat(pull-usrlocalsrc): Use fixed remote `origin`
[git-scripts.git] / pull-usrlocalsrc
index 04f856df5e00ce2e44beb5b17e0e03916dfddb8e..1413803bf598da1d04b88d1777ab870b29401156 100755 (executable)
@@ -1,9 +1,17 @@
 #! /bin/sh
 
+has_remote() {
+   git remote show "$1" >/dev/null 2>&1
+}
+
 prog_dir="`dirname \"$0\"`" &&
 
 cat "$prog_dir"/locate-all.list | grep -F /usr/local/src |
 while read d; do
    echo "----- $d -----"; cd "$d" &&
-   git remote | xargs -I'{}' git pull '{}' master || exit 1
+   if has_remote upstream && has_remote origin; then
+      git pull upstream master && git push origin master || exit 1
+   elif has_remote origin; then
+      git pull origin master || exit 1
+   fi
 done