chiark / gitweb /
tg-update.sh: Better explain base update
[topgit.git] / tg-update.sh
index 563a62d8fbb293b4140fdd17067caf552d215e9c..5caf6910a17f7c39906fe6456bd550faf4b537c2 100644 (file)
@@ -21,7 +21,7 @@ base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)"
 
 ## First, take care of our base
 
-depcheck="$(mktemp)"
+depcheck="$(mktemp -t tg-depcheck.XXXXXX)"
 missing_deps=
 needs_update "$name" >"$depcheck" || :
 [ -z "$missing_deps" ] || die "some dependencies are missing: $missing_deps"
@@ -39,13 +39,13 @@ if [ -s "$depcheck" ]; then
                sed 's/^\([^+]\)/-\1/' | # now each line is +branch or -branch (+ == recurse)
                uniq -s 1 | # fold branch lines; + always comes before - and thus wins within uniq
                while read depline; do
-                       action="${depline:0:1}"
-                       dep="${depline:1}"
+                       action="$(echo "$depline" | cut -c 1)"
+                       dep="$(echo "$depline" | cut -c 2-)"
 
                        # We do not distinguish between dependencies out-of-date
-                       # and base out-of-date cases for $dep here, but thanks
-                       # to needs_update returning : for the latter, we do
-                       # correctly recurse here in both cases.
+                       # and base out-of-date cases for $dep here,
+                       # but thanks to needs_update returning : for the latter,
+                       # we do correctly recurse here in both cases.
 
                        if [ x"$action" = x+ ]; then
                                info "Recursing to $dep..."
@@ -67,6 +67,12 @@ if [ -s "$depcheck" ]; then
                                switch_to_base "$name"
                        fi
 
+                       # This will always be a proper topic branch
+                       # (not a base or remote), since for deep updates
+                       # we recurse and immediate dependencies
+                       # are always proper. (branch_needs_update() is called
+                       # only on the _dependencies_, not our branch itself!)
+
                        info "Updating base with $dep changes..."
                        if ! git merge "$dep"; then
                                if [ -z "$TG_RECURSIVE" ]; then