{"thread":{"id":"33124","subject":"[PATCH 05/19] A number of changes to push_all and pull_all:","startedAt":"2013-03-09T19:24:36Z","lastAt":"2013-03-09T19:24:36Z","messageCount":1,"participants":["Paul Campbell"],"isPatch":true,"patchVersion":1,"patchTotal":19},"messages":[{"id":"210912","messageId":"CALeLG_=D7PYhUdCqo=z7-Ss-UirnwhZconPR=Pp5Q4iBuX6Q1g@mail.gmail.com","threadId":"33124","inReplyTo":null,"subject":"[PATCH 05/19] A number of changes to push_all and pull_all:","fromName":"Paul Campbell","fromEmail":"pcampbell@kemitix.net","sentAt":"2013-03-09T19:24:36Z","receivedAt":"2013-03-09T19:24:36Z","isPatch":true,"sender":{"key":"pcampbell@kemitix.net","avatar":"https://gravatar.com/avatar/57584e05501b694929004e43fcd7308f4ad64df2eb0474cd8c7e5f93662bb0f1?d=mp&s=160"},"body":">From 10f2260165d6be3a6ab477ed38fd8ab0308c11e6 Mon Sep 17 00:00:00 2001\nFrom: Paul Campbell <pcampbell@kemitix.net>\nDate: Sat, 9 Mar 2013 18:31:59 +0000\nSubject: [PATCH 05/19] A number of changes to push_all and pull_all:\n\n* adding commands in \"add\" to populate the .gittrees file\n* changing underscores to dashes (push_all -> push-all)\n* changing commands to not be hardcoded to branch \"master\" from remote\n* letting the user specify 0, 1, or 2 arguments to push and pull, like\nnormal \"git push\" and \"git pull\".  We'll try to look up missing\ninformation from .gittrees, like git normally does from .git/config\n\nConflicts:\n\t.gitignore\n\tcontrib/subtree/git-subtree.sh\n\nOriginal-Author: mhoffman <matt.hoffman@quantumretail.com>\nConflicts-resolved-by: Paul Campbell <pcampbell@kemitix.net>\n---\n contrib/subtree/git-subtree.sh | 57 ++++++++++++++++++++++++++++++------------\n 1 file changed, 41 insertions(+), 16 deletions(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex c3b1208..74e4c74 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -12,7 +12,8 @@ git subtree add   --prefix=<prefix> <commit>\n git subtree add   --prefix=<prefix> <repository> <commit>\n git subtree merge --prefix=<prefix> <commit>\n git subtree pull  --prefix=<prefix> <repository> <refspec...>\n-git subtree pull_all\n+git subtree pull-all\n+git subtree push-all\n git subtree push  --prefix=<prefix> <repository> <refspec...>\n git subtree split --prefix=<prefix> <commit...>\n git subtree from-submodule --prefix=<prefix>\n@@ -103,18 +104,18 @@ done\n command=\"$1\"\n shift\n case \"$command\" in\n-\tadd|merge|pull|from-submodule|pull_all|push_all) default= ;;\n+\tadd|merge|pull|from-submodule|pull-all|push-all) default= ;;\n \tsplit|push) default=\"--default HEAD\" ;;\n \t*) die \"Unknown command '$command'\" ;;\n esac\n\n-if [ -z \"$prefix\" -a \"$command\" != \"pull_all\" -a \"$command\" !=\n\"push_all\" ]; then\n+if [ -z \"$prefix\" -a \"$command\" != \"pull-all\" -a \"$command\" !=\n\"push-all\" ]; then\n \tdie \"You must provide the --prefix option.\"\n fi\n\n case \"$command\" in\n-    pull_all);;\n-    push_all);;\n+    pull-all);;\n+    push-all);;\n \tadd) [ -e \"$prefix\" ] &&\n \t\tdie \"prefix '$prefix' already exists.\" ;;\n \t*)   [ -e \"$prefix\" ] ||\n@@ -123,7 +124,7 @@ esac\n\n dir=\"$(dirname \"$prefix/.\")\"\n\n-if [ \"$command\" != \"pull\" -a \"$command\" != \"add\" -a \"$command\" !=\n\"push\" -a \"$command\" != \"pull_all\" ]; then\n+if [ \"$command\" != \"pull\" -a \"$command\" != \"add\" -a \"$command\" !=\n\"push\" -a \"$command\" != \"pull-all\" ]; then\n \trevs=$(git rev-parse $default --revs-only \"$@\") || exit $?\n \tdirs=\"$(git rev-parse --no-revs --no-flags \"$@\")\" || exit $?\n \tif [ -n \"$dirs\" ]; then\n@@ -531,6 +532,14 @@ cmd_add_repository()\n \trevs=FETCH_HEAD\n \tset -- $revs\n \tcmd_add_commit \"$@\"\n+\n+  # now add it to our list of repos\n+  git config -f .gittrees --unset subtree.$dir.url\n+  git config -f .gittrees --add subtree.$dir.url $repository\n+  git config -f .gittrees --unset subtree.$dir.path\n+  git config -f .gittrees --add subtree.$dir.path $dir\n+  git config -f .gittrees --unset subtree.$dir.branch\n+  git config -f .gittrees --add subtree.$dir.branch $refspec\n }\n\n cmd_add_commit()\n@@ -704,13 +713,21 @@ cmd_merge()\n\n cmd_pull()\n {\n-    if [ $# -ne 1 ]; then\n-\t    die \"You must provide <branch>\"\n+  if [ $# -gt 2 ]; then\n+\t    die \"You should provide either <refspec> or <repository> <refspec>\"\n \tfi\n \tif [ -e \"$dir\" ]; then\n \t    ensure_clean\n-\t    repository=$(git config -f .gittrees subtree.$prefix.url)\n-\t    refspec=$1\n+      if [ $# -eq 1 ]; then\n+\t      repository=$(git config -f .gittrees subtree.$prefix.url)\n+\t      refspec=$1\n+      elif [ $# -eq 2 ]; then\n+        repository=$1\n+        refspec=$2\n+      else\n+\t      repository=$(git config -f .gittrees subtree.$prefix.url)\n+        refspec=$(git config -f .gittrees subtree.$prefix.branch)\n+      fi\n \t    git fetch $repository $refspec || exit $?\n \t    echo \"git fetch using: \" $repository $refspec\n \t    revs=FETCH_HEAD\n@@ -723,12 +740,20 @@ cmd_pull()\n\n cmd_push()\n {\n-\tif [ $# -ne 1 ]; then\n-\t    die \"You must provide <branch>\"\n+\tif [ $# -gt 2 ]; then\n+\t    die \"You shold provide either <refspec> or <repository> <refspec>\"\n \tfi\n \tif [ -e \"$dir\" ]; then\n-\t    repository=$(git config -f .gittrees subtree.$prefix.url)\n-\t    refspec=$1\n+      if [ $# -eq 1 ]; then\n+\t      repository=$(git config -f .gittrees subtree.$prefix.url)\n+        refspec=$1\n+      elif [ $# -eq 2 ]; then\n+        repository=$1\n+        refspec=$2\n+      else\n+\t      repository=$(git config -f .gittrees subtree.$prefix.url)\n+        refspec=$(git config -f .gittrees subtree.$prefix.branch)\n+      fi\n \t    echo \"git push using: \" $repository $refspec\n \t    git push $repository $(git subtree split\n--prefix=$prefix):refs/heads/$refspec\n \telse\n@@ -763,7 +788,7 @@ cmd_from-submodule()\n \trm -rf $tmp_repo\n }\n\n-cmd_pull_all()\n+cmd_pull-all()\n {\n     git config -f .gittrees -l | grep subtree | grep path | grep -o\n'=.*' | grep -o '[^=].*' |\n         while read path; do\n@@ -771,7 +796,7 @@ cmd_pull_all()\n         done\n }\n\n-cmd_push_all()\n+cmd_push-all()\n {\n     git config -f .gittrees -l | grep subtree | grep path | grep -o\n'=.*' | grep -o '[^=].*' |\n         while read path; do\n-- \n1.8.2.rc1\n\n\n-- \nPaul [W] Campbell\n"}]}