formatting
[feisty_meow.git] / scripts / rev_control / version_control.sh
index ccb14c25d577784d480f4dfa77b375c45b7c7ca8..a37c24372710a190d334705ce842966a36bc999e 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.
@@ -76,22 +87,22 @@ function do_checkin()
       if ! git diff-index --quiet HEAD --; then
         # tell git about all the files and get a check-in comment.
         git commit .
-        retval+=$?
+        let "retval = retval + $?"
       fi
       # catch if the diff-index failed somehow.
-      retval+=$?
+      let "retval = retval + $?"
 
       local myself="$(my_branch_name)"
       local parent="$(parent_branch_name)"
 
       # upload any changes to the upstream repo so others can see them.
       if [ "$myself" != "$parent" ]; then
-        git push origin "$(myself)" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
-        retval+=${PIPESTATUS[0]}
+        git push origin "$(myself)" 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+        let "retval = 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" | squash_first_few_crs
-        retval+=${PIPESTATUS[0]}
+        git push 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+        let "retval = retval + ${PIPESTATUS[0]}"
       fi
 
     fi
@@ -120,13 +131,13 @@ function do_diff
   # only update if we see a repository living there.
   if [ -d ".svn" ]; then
     svn diff .
-    retval+=$?
+    let "retval = retval + $?"
   elif [ -d ".git" ]; then
     git diff 
-    retval+=$?
+    let "retval = retval + $?"
   elif [ -d "CVS" ]; then
     cvs diff .
-    retval+=$?
+    let "retval = retval + $?"
   fi
 
   popd &>/dev/null
@@ -264,16 +275,29 @@ function do_update()
     if test_writeable ".git"; then
       $blatt
       retval=0
-      local myself="$(my_branch_name)"
-      local parent="$(parent_branch_name)"
 
-      if [ "$myself" != "$parent" ]; then
-        git pull origin "$parent" 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
-        retval+=${PIPESTATUS[0]}
-      else
-        git pull 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
-        retval+=${PIPESTATUS[0]}
-      fi
+      # from very helpful page:
+      # https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches
+
+      for remote in $( git branch -r | grep -v -- '->' ); do
+        git branch --track ${remote#origin/} $remote
+        let "retval = retval + $?"
+      done
+
+#tiny bit hosed
+#      git branch -r | grep -v -- '->' |
+#          while read remote; do
+#            git branch --track "${remote#origin/}" "$remote"
+#            # ensure we notice a failure when adding tracking.
+#            let "retval = retval + $?"
+#          done
+#      let "retval = retval + ${PIPESTATUS[0]}"
+
+      git fetch --all 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+      let "retval = retval + ${PIPESTATUS[0]}"
+
+      git pull --all 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+      let "retval = retval + ${PIPESTATUS[0]}"
     fi
   else
     # this is not an error necessarily; we'll just pretend they planned this.
@@ -371,4 +395,3 @@ function perform_revctrl_action_on_file()
   rm $tempfile
 }
 
-