X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-merge.sh;h=d049e164318a416941334b15699d52f87b00387f;hb=cc4c4f0ce25cc3803197bc19c275fd6f59a2a511;hp=af1f25b3c51d197ea5fd24b7623dfb591f867133;hpb=7d55561986ffe94ca7ca22dc0a6846f698893226;p=git.git diff --git a/git-merge.sh b/git-merge.sh index af1f25b3c..d049e1643 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,22 +3,26 @@ # Copyright (c) 2005 Junio C Hamano # - -USAGE='[-n] [--no-commit] [-s ]... +' +USAGE='[-n] [--no-commit] [--squash] [-s ]... +' . git-sh-setup LF=' ' -all_strategies='recursive octopus resolve stupid ours' -default_twohead_strategies='recursive' +all_strategies='recursive recur octopus resolve stupid ours' +case "${GIT_USE_RECUR_FOR_RECURSIVE}" in +'') + default_twohead_strategies=recursive ;; +?*) + default_twohead_strategies=recur ;; +esac default_octopus_strategies='octopus' no_trivial_merge_strategies='ours' use_strategies= index_merge=t if test "@@NO_PYTHON@@"; then - all_strategies='resolve octopus stupid ours' + all_strategies='recur resolve octopus stupid ours' default_twohead_strategies='resolve' fi @@ -42,30 +46,68 @@ restorestate() { fi } -finish () { - test '' = "$2" || echo "$2" - case "$merge_msg" in +finish_up_to_date () { + case "$squash" in + t) + echo "$1 (nothing to squash)" ;; '') - echo "No merge message -- not updating HEAD" + echo "$1" ;; + esac + dropsave +} + +squash_message () { + echo Squashed commit of the following: + echo + git-log --no-merges ^"$head" $remote +} + +finish () { + if test '' = "$2" + then + rlogm="$rloga" + else + echo "$2" + rlogm="$rloga: $2" + fi + case "$squash" in + t) + echo "Squash commit -- not updating HEAD" + squash_message >"$GIT_DIR/SQUASH_MSG" ;; - *) - git-update-ref HEAD "$1" "$head" || exit 1 + '') + case "$merge_msg" in + '') + echo "No merge message -- not updating HEAD" + ;; + *) + git-update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1 + ;; + esac ;; esac - - case "$no_summary" in + case "$1" in '') - git-diff-tree -p --stat --summary -M "$head" "$1" + ;; + ?*) + case "$no_summary" in + '') + git-diff-tree --stat --summary -M "$head" "$1" + ;; + esac ;; esac } +rloga= while case "$#" in 0) break ;; esac do case "$1" in -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\ --no-summa|--no-summar|--no-summary) no_summary=t ;; + --sq|--squ|--squa|--squas|--squash) + squash=t no_commit=t ;; --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) no_commit=t ;; -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ @@ -73,13 +115,17 @@ do -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) case "$#,$1" in *,*=*) - strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;; + strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; 1,*) usage ;; *) strategy="$2" shift ;; esac + case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in + recursive,?*) + strategy=recur ;; + esac case " $all_strategies " in *" $strategy "*) use_strategies="$use_strategies$strategy " ;; @@ -87,6 +133,9 @@ do die "available strategies are: $all_strategies" ;; esac ;; + --reflog-action=*) + rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; -*) usage ;; *) break ;; esac @@ -101,6 +150,7 @@ shift # All the rest are remote heads test "$#" = 0 && usage ;# we need at least one remote head. +test "$rloga" = '' && rloga="merge: $@" remoteheads= for remote @@ -152,8 +202,7 @@ f,*) ?,1,"$1",*) # If head can reach all the merge then we are up to date. # but first the most common case of merging one remote. - echo "Already up-to-date." - dropsave + finish_up_to_date "Already up-to-date." exit 0 ;; ?,1,"$head",*) @@ -205,8 +254,7 @@ f,*) done if test "$up_to_date" = t then - echo "Already up-to-date. Yeeah!" - dropsave + finish_up_to_date "Already up-to-date. Yeeah!" exit 0 fi ;; @@ -288,7 +336,7 @@ if test '' != "$result_tree" then parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /') result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit - finish "$result_commit" "Merge $result_commit, made by $wt_strategy." + finish "$result_commit" "Merge made by $wt_strategy." dropsave exit 0 fi @@ -310,11 +358,17 @@ case "$best_strategy" in git-merge-$best_strategy $common -- "$head_arg" "$@" ;; esac -for remote -do - echo $remote -done >"$GIT_DIR/MERGE_HEAD" -echo "$merge_msg" >"$GIT_DIR/MERGE_MSG" + +if test "$squash" = t +then + finish +else + for remote + do + echo $remote + done >"$GIT_DIR/MERGE_HEAD" + echo "$merge_msg" >"$GIT_DIR/MERGE_MSG" +fi if test "$merge_was_ok" = t then