Merge branch 'maint'
[gitweb.git] / git-merge.sh
index 1c4f6693f5b6919da2a867a02465a382477cfcac..fa4589173f426d6172883c47479c52b8700cafa8 100755 (executable)
@@ -5,11 +5,13 @@
 
 USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
 
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
-set_reflog_action "merge $*"
+require_work_tree
+cd_to_toplevel
 
 test -z "$(git ls-files -u)" ||
-       die "You are in a middle of conflicted merge."
+       die "You are in the middle of a conflicted merge."
 
 LF='
 '
@@ -106,6 +108,10 @@ merge_name () {
                git-show-ref -q --verify "refs/heads/$truname" 2>/dev/null
        then
                echo "$rh               branch '$truname' (early part) of ."
+       elif test "$remote" = "FETCH_HEAD" -a -r "$GIT_DIR/FETCH_HEAD"
+       then
+               sed -e 's/      not-for-merge   /               /' -e 1q \
+                       "$GIT_DIR/FETCH_HEAD"
        else
                echo "$rh               commit '$remote'"
        fi
@@ -214,6 +220,7 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage
 
 # All the rest are remote heads
 test "$#" = 0 && usage ;# we need at least one remote head.
+set_reflog_action "merge $*"
 
 remoteheads=
 for remote
@@ -230,7 +237,7 @@ case "$use_strategies" in
 '')
        case "$#" in
        1)
-               var="`git-repo-config --get pull.twohead`"
+               var="`git-config --get pull.twohead`"
                if test -n "$var"
                then
                        use_strategies="$var"
@@ -238,7 +245,7 @@ case "$use_strategies" in
                        use_strategies="$default_twohead_strategies"
                fi ;;
        *)
-               var="`git-repo-config --get pull.octopus`"
+               var="`git-config --get pull.octopus`"
                if test -n "$var"
                then
                        use_strategies="$var"
@@ -251,12 +258,15 @@ esac
 
 for s in $use_strategies
 do
-       case " $s " in
-       *" $no_trivial_merge_strategies "*)
-               index_merge=f
-               break
-               ;;
-       esac
+       for nt in $no_trivial_merge_strategies
+       do
+               case " $s " in
+               *" $nt "*)
+                       index_merge=f
+                       break
+                       ;;
+               esac
+       done
 done
 
 case "$#" in
@@ -286,9 +296,14 @@ f,*)
        # Again the most common case of merging one remote.
        echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $1)"
        git-update-index --refresh 2>/dev/null
+       msg="Fast forward"
+       if test -n "$have_message"
+       then
+               msg="$msg (no commit created; -m option ignored)"
+       fi
        new_head=$(git-rev-parse --verify "$1^0") &&
        git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" &&
-       finish "$new_head" "Fast forward"
+       finish "$new_head" "$msg" || exit
        dropsave
        exit 0
        ;;