From: bibendi <bibe...@bk.ru>

For each subtree listed in .gittrees perform a push or a pull.

Signed-off-by: Paul Campbell <pcampb...@kemitix.net>

Conflicts:
        contrib/subtree/git-subtree.sh
---
 contrib/subtree/git-subtree.sh | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 1aff956..ddae56e 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -12,6 +12,7 @@ git subtree add   --prefix=<prefix> <commit>
 git subtree add   --prefix=<prefix> <repository> <commit>
 git subtree merge --prefix=<prefix> <commit>
 git subtree pull  --prefix=<prefix> <repository> <refspec...>
+git subtree pull_all
 git subtree push  --prefix=<prefix> <repository> <refspec...>
 git subtree split --prefix=<prefix> <commit...>
 git subtree from-submodule --prefix=<prefix>
@@ -102,16 +103,18 @@ done
 command="$1"
 shift
 case "$command" in
-       add|merge|pull|from-submodule) default= ;;
+       add|merge|pull|from-submodule|pull_all|push_all) default= ;;
        split|push) default="--default HEAD" ;;
        *) die "Unknown command '$command'" ;;
 esac
 
-if [ -z "$prefix" ]; then
+if [ -z "$prefix" -a "$command" != "pull_all" -a "$command" != "push_all" ]; 
then
        die "You must provide the --prefix option."
 fi
 
 case "$command" in
+    pull_all);;
+    push_all);;
        add) [ -e "$prefix" ] && 
                die "prefix '$prefix' already exists." ;;
        *)   [ -e "$prefix" ] || 
@@ -120,7 +123,7 @@ esac
 
 dir="$(dirname "$prefix/.")"
 
-if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" ]; 
then
+if [ "$command" != "pull" -a "$command" != "add" -a "$command" != "push" -a 
"$command" != "pull_all" ]; then
        revs=$(git rev-parse $default --revs-only "$@") || exit $?
        dirs="$(git rev-parse --no-revs --no-flags "$@")" || exit $?
        if [ -n "$dirs" ]; then
@@ -767,4 +770,20 @@ cmd_from-submodule()
        rm -rf $tmp_repo
 }
 
+cmd_pull_all()
+{
+    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | 
grep -o '[^=].*' |
+        while read path; do
+            git subtree pull -P $path master || exit $?
+        done
+}
+
+cmd_push_all()
+{
+    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | 
grep -o '[^=].*' |
+        while read path; do
+            git subtree push -P $path master || exit $?
+        done
+}
+
 "cmd_$command" "$@"
-- 
1.8.2.rc1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to