]> git.phdru.name Git - git-scripts.git/blobdiff - pull-usrlocalsrc
Feat(submodules/remove): Add option `-c`
[git-scripts.git] / pull-usrlocalsrc
index 2f4c029cb6a4b1d26d8d420a6b99393e29e2246f..c7159ada349311b42b2170e494c4c84c7621f9dd 100755 (executable)
@@ -1,9 +1,18 @@
 #! /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 true; do
-   read d || exit 0
-   echo "----- $d -----"; cd "$d" && git pull origin || exit 1
+while read d; do
+   echo "----- $d -----"; cd "$d" &&
+   if has_remote upstream && has_remote origin; then
+      { git pull upstream master || git pull upstream main:master; } &&
+         git push origin master || exit 1
+   elif has_remote origin; then
+      git pull origin master || git pull origin main:master || exit 1
+   fi
 done