[cogito] Sync objects only when needed...

From: Michal Rokos <hidden>
Date: 2016-06-15 22:41:58

Hello,

during the day I'm usually connected via modem so syncing all the objects via rsync is painful.

So, is there any reason to sync them even if remote and and local origin head are the same?

 Michal

PS: I'm off the list, so please CC me.

Signed-off-by: Michal Rokos <redacted>

Index: cg-pull
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-pull  (mode:100755)
+++ uncommitted/cg-pull  (mode:100755)
@@ -9,8 +9,14 @@
 
 . ${COGITO_LIB}cg-Xlib
 
-name=$1
+force=
 
+if [ "$1" == "-f" ]; then
+ force=1
+ shift
+fi
+
+name=$1
 
 [ "$name" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }
 [ "$name" ] || die "where to pull from?"
@@ -199,6 +205,22 @@
 fi
 [ "$rsyncerr" ] && die "unable to get the head pointer of branch $rembranch"
 
+new_head=$(cat "$_git/refs/heads/$name")
+
+if [ ! "$orig_head" ]; then
+ echo "New branch: $new_head"
+
+elif [ "$orig_head" != "$new_head" ]; then
+ echo "Tree change: $orig_head:$new_head"
+
+elif [ -n "$force" ]; then
+ echo "Update forced..."
+
+else
+ echo "Up to date."
+ exit
+fi
+
 [ -d $_git_objects ] || mkdir -p $_git_objects
 $pull "$name" "$uri" || die "objects pull failed"
 
@@ -215,8 +237,6 @@
 [ "$rsyncerr" ] && echo "unable to get tags list (non-fatal)" >&2
 
 
-new_head=$(cat "$_git/refs/heads/$name")
-
 if [ ! "$orig_head" ]; then
  echo "New branch: $new_head"
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help