yet another tweak to fix pipes
[feisty_meow.git] / scripts / rev_control / version_control.sh
index 3eaa05ba6ae8e9149b806962d03ac294e08ff00c..e7b29b0110ac7a86c512dad134c2fa7c1f44256f 100644 (file)
@@ -6,11 +6,22 @@
 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
 
+#hmmm: we need to dump all the outputs in this script into splitter
+
 ##############
 
 # the maximum depth that the recursive functions will try to go below the starting directory.
 export MAX_DEPTH=5
 
+# use our splitter tool for lengthy output if it's available.
+if [ ! -z "$(which splitter)" ]; then
+  TO_SPLITTER="$(which splitter)"
+else
+  TO_SPLITTER=cat
+fi
+
+##############
+
 # one unpleasantry to take care of first; cygwin barfs aggressively if the TMP directory
 # is a DOS path, but we need it to be a DOS path for our GFFS testing, so that blows.
 # to get past this, TMP gets changed below to a hopefully generic and safe place.
@@ -81,13 +92,16 @@ function do_checkin()
       # catch if the diff-index failed somehow.
       retval+=$?
 
-#push the changes to where?  locally?
-      git push 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
-      retval+=${PIPESTATUS[0]}
+      local myself="$(my_branch_name)"
+      local parent="$(parent_branch_name)"
 
       # upload any changes to the upstream repo so others can see them.
-      if [ "$(my_branch_name)" != "master" ]; then
-        git push origin "$(my_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
+      if [ "$myself" != "$parent" ]; then
+        git push origin "$(myself)" 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+        retval+=${PIPESTATUS[0]}
+      else
+        # this branch is the same as the parent, so just push.
+        git push 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
         retval+=${PIPESTATUS[0]}
       fi
 
@@ -262,10 +276,20 @@ function do_update()
       $blatt
       retval=0
 
-      git pull origin "$(parent_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
+      # from very helpful page:
+      # https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches
+      git branch -r | grep -v '\->' |
+          while read remote; do
+            git branch --track "${remote#origin/}" "$remote"
+            # ensure we notice a failure when adding tracking.
+            retval+=$?
+          done
+      retval+=${PIPESTATUS[0]}$?
+
+      git fetch --all 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
       retval+=${PIPESTATUS[0]}
 
-      git pull origin "$(my_branch_name)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
+      git pull --all 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
       retval+=${PIPESTATUS[0]}
     fi
   else