X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-commit-script;h=a2455b0f8ff1582248b0678b9c85b2f064d972c4;hb=f5f2c52bb08a7fc5bde6a7eb6552235df9daca71;hp=5c5f564a28e779de333ea96c35c95993f7535869;hpb=89e2c5f17b901edf28a8bb778ece3f6c18bbb721;p=git.git diff --git a/git-commit-script b/git-commit-script index 5c5f564a..a2455b0f 100755 --- a/git-commit-script +++ b/git-commit-script @@ -64,6 +64,9 @@ do use_commit="$1" no_edit=t shift ;; + -e|--e|--ed|--edi|--edit) + no_edit= + shift ;; -s|--s|--si|--sig|--sign|--signo|--signof|--signoff) signoff=t shift ;; @@ -110,57 +113,54 @@ t) fi esac +if test "$log_message" != '' +then + echo "$log_message" +elif test "$logfile" != "" +then + if test "$logfile" = - + then + test -t 0 && + echo >&2 "(reading log message from standard input)" + cat + else + cat <"$logfile" + fi +elif test "$use_commit" != "" +then + git-cat-file commit "$use_commit" | sed -e '1,/^$/d' +fi | git-stripspace >.editmsg + +case "$signoff" in +t) + git-var GIT_COMMITTER_IDENT | sed -e ' + s/>.*/>/ + s/^/Signed-off-by: / + ' >>.editmsg + ;; +esac + +if [ -f "$GIT_DIR/MERGE_HEAD" ]; then + echo "#" + echo "# It looks like your may be committing a MERGE." + echo "# If this is not correct, please remove the file" + echo "# $GIT_DIR/MERGE_HEAD" + echo "# and try again" + echo "#" +fi >>.editmsg + PARENTS="-p HEAD" if [ ! -r "$GIT_DIR/HEAD" ]; then if [ -z "$(git-ls-files)" ]; then echo Nothing to commit 1>&2 exit 1 fi - { - echo "#" - echo "# Initial commit" - case "$no_edit" in - t) echo "# (ignoring your commit message for initial commit)" - no_edit= - esac - echo "#" - git-ls-files | sed 's/^/# New file: /' - echo "#" - } >.editmsg PARENTS="" - no_edit= else if [ -f "$GIT_DIR/MERGE_HEAD" ]; then - { - echo "#" - echo "# It looks like your may be committing a MERGE." - echo "# If this is not correct, please remove the file" - echo "# $GIT_DIR/MERGE_HEAD" - echo "# and try again" - case "$no_edit" in - t) echo "# (ignoring your commit message for merge commit)" - no_edit= - esac - echo "#" - } | - git-stripspace >.editmsg PARENTS="-p HEAD -p MERGE_HEAD" - elif test "$log_message" != '' - then - echo "$log_message" | - git-stripspace >.editmsg - elif test "$logfile" != "" - then - if test "$logfile" = - - then - test -t 0 && - echo >&2 "(reading log message from standard input)" - cat - else - cat <"$logfile" - fi | - git-stripspace >.editmsg - elif test "$use_commit" != "" + fi + if test "$use_commit" != "" then pick_author_script=' /^author /{ @@ -188,23 +188,13 @@ else export GIT_AUTHOR_NAME export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE - git-cat-file commit "$use_commit" | - sed -e '1,/^$/d' | - git-stripspace >.editmsg fi - - case "$signoff" in - t) - git-var GIT_COMMITTER_IDENT | sed -e ' - s/>.*/>/ - s/^/Signed-off-by: /' >>.editmsg ;; - esac - git-status-script >>.editmsg fi +git-status-script >>.editmsg if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ] then - cat .editmsg - rm .editmsg + rm -f .editmsg + git-status-script exit 1 fi case "$no_edit" in