git-merge --squash
[gitweb.git] / git-commit.sh
index 15482d21b31dadaf53bf831be2de4d6f8b269b33..9f49651cfdce101af3ba2c1980121d9ccea8a194 100755 (executable)
@@ -199,6 +199,7 @@ only=
 logfile=
 use_commit=
 amend=
+edit_flag=
 no_edit=
 log_given=
 log_message=
@@ -246,7 +247,7 @@ do
       shift
       ;;
   -e|--e|--ed|--edi|--edit)
-      no_edit=
+      edit_flag=t
       shift
       ;;
   -i|--i|--in|--inc|--incl|--inclu|--includ|--include)
@@ -384,6 +385,7 @@ $1"
       ;;
   esac
 done
+case "$edit_flag" in t) no_edit= ;; esac
 
 ################################################################
 # Sanity check options
@@ -564,6 +566,9 @@ then
 elif test -f "$GIT_DIR/MERGE_HEAD" && test -f "$GIT_DIR/MERGE_MSG"
 then
        cat "$GIT_DIR/MERGE_MSG"
+elif test -f "$GIT_DIR/SQUASH_MSG"
+then
+       cat "$GIT_DIR/SQUASH_MSG"
 fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
 
 case "$signoff" in
@@ -661,7 +666,7 @@ else
 fi
 if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
 then
-       rm -f "$GIT_DIR/COMMIT_EDITMSG"
+       rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
        run_status
        exit 1
 fi
@@ -713,7 +718,8 @@ then
                rm -f "$TMP_INDEX"
        fi &&
        commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
-       git-update-ref HEAD $commit $current &&
+       rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
+       git-update-ref -m "commit: $rlogm" HEAD $commit $current &&
        rm -f -- "$GIT_DIR/MERGE_HEAD" &&
        if test -f "$NEXT_INDEX"
        then
@@ -726,7 +732,7 @@ else
        false
 fi
 ret="$?"
-rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG"
+rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
 if test -d "$GIT_DIR/rr-cache"
 then
        git-rerere