merge_msg() is really more like rejoin_msg().
[gitweb.git] / git-subtree.sh
index ea0294fb79d969b37bf15ca6b051227feb13f822..d82e03e6fd295d575ac23624a87f0e41145f4f40 100755 (executable)
@@ -23,6 +23,8 @@ 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 'merge' and 'pull'
+squash        merge subtree changes as a single commit
 "
 eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
 . git-sh-setup
@@ -36,6 +38,7 @@ onto=
 rejoin=
 ignore_joins=
 annotate=
+squash=
 
 debug()
 {
@@ -80,6 +83,8 @@ while [ $# -gt 0 ]; do
                --no-rejoin) rejoin= ;;
                --ignore-joins) ignore_joins=1 ;;
                --no-ignore-joins) ignore_joins= ;;
+               --squash) squash=1 ;;
+               --no-squash) squash= ;;
                --) break ;;
                *) die "Unexpected option: $opt" ;;
        esac
@@ -173,15 +178,15 @@ find_existing_splits()
                case "$a" in
                        git-subtree-mainline:) main="$b" ;;
                        git-subtree-split:) sub="$b" ;;
-                       *)
+                       END)
                                if [ -n "$main" -a -n "$sub" ]; then
                                        debug "  Prior: $main -> $sub"
                                        cache_set $main $sub
                                        try_remove_previous "$main"
                                        try_remove_previous "$sub"
-                                       main=
-                                       sub=
                                fi
+                               main=
+                               sub=
                                ;;
                esac
        done
@@ -225,7 +230,7 @@ add_msg()
        EOF
 }
 
-merge_msg()
+rejoin_msg()
 {
        dir="$1"
        latest_old="$2"
@@ -405,6 +410,9 @@ cmd_split()
                
                tree=$(subtree_for_commit $rev "$dir")
                debug "  tree is: $tree"
+               
+               # ugly.  is there no better way to tell if this is a subtree
+               # vs. a mainline commit?  Does it matter?
                [ -z $tree ] && continue
 
                newrev=$(copy_or_skip "$rev" "$tree" "$newparents") || exit $?
@@ -422,7 +430,7 @@ cmd_split()
                debug "Merging split branch into HEAD..."
                latest_old=$(cache_get latest_old)
                git merge -s ours \
-                       -m "$(merge_msg $dir $latest_old $latest_new)" \
+                       -m "$(rejoin_msg $dir $latest_old $latest_new)" \
                        $latest_new >&2 || exit $?
        fi
        if [ -n "$branch" ]; then