Merge branch 'js/gc-with-stale-symref'
[gitweb.git] / contrib / subtree / git-subtree.sh
index 39c7d54ce8029369189e2f796d658a65a61fd402..308b777b0aa43a7466fb3402cc67c1f023f57a7a 100755 (executable)
@@ -26,7 +26,7 @@ b,branch=     create a new branch from the split subtree
 ignore-joins  ignore prior --rejoin commits
 onto=         try connecting new tree to an existing one
 rejoin        merge the new branch back into HEAD
- options for 'add', 'merge', 'pull' and 'push'
+ options for 'add', 'merge', and 'pull'
 squash        merge subtree changes as a single commit
 "
 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
@@ -51,14 +51,21 @@ prefix=
 debug()
 {
        if [ -n "$debug" ]; then
-               echo "$@" >&2
+               printf "%s\n" "$*" >&2
        fi
 }
 
 say()
 {
        if [ -z "$quiet" ]; then
-               echo "$@" >&2
+               printf "%s\n" "$*" >&2
+       fi
+}
+
+progress()
+{
+       if [ -z "$quiet" ]; then
+               printf "%s\r" "$*" >&2
        fi
 }
 
@@ -599,7 +606,7 @@ cmd_split()
        eval "$grl" |
        while read rev parents; do
                revcount=$(($revcount + 1))
-               say -n "$revcount/$revmax ($createcount)\r"
+               progress "$revcount/$revmax ($createcount)"
                debug "Processing commit: $rev"
                exists=$(cache_get $rev)
                if [ -n "$exists" ]; then
@@ -641,7 +648,7 @@ cmd_split()
                debug "Merging split branch into HEAD..."
                latest_old=$(cache_get latest_old)
                git merge -s ours \
-                       -m "$(rejoin_msg $dir $latest_old $latest_new)" \
+                       -m "$(rejoin_msg "$dir" $latest_old $latest_new)" \
                        $latest_new >&2 || exit $?
        fi
        if [ -n "$branch" ]; then
@@ -728,7 +735,7 @@ cmd_push()
            refspec=$2
            echo "git push using: " $repository $refspec
            localrev=$(git subtree split --prefix="$prefix") || die
-           git push $repository $localrev:refs/heads/$refspec
+           git push "$repository" $localrev:refs/heads/$refspec
        else
            die "'$dir' must already exist. Try 'git subtree add'."
        fi