git-commit-scripton commit Merge master.kernel.org:/pub/scm/gitk/gitk (07ee0d7)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Linus Torvalds
   4#
   5
   6. git-sh-setup-script || die "Not a git archive"
   7
   8usage () {
   9        die 'git commit [-m existing-commit] [<path>...]'
  10}
  11
  12while case "$#" in 0) break ;; esac
  13do
  14    case "$1" in
  15    -m) shift
  16        case "$#" in
  17        0) usage ;;
  18        *) use_commit=`git-rev-parse "$1"` ||
  19           exit ;;
  20        esac
  21        ;;
  22    *)  break
  23        ;;
  24    esac
  25    shift
  26done
  27
  28git-update-cache -q --refresh -- "$@" || exit 1
  29PARENTS="-p HEAD"
  30if [ ! -r "$GIT_DIR/HEAD" ]; then
  31        if [ -z "$(git-ls-files)" ]; then
  32                echo Nothing to commit 1>&2
  33                exit 1
  34        fi
  35        (
  36                echo "#"
  37                echo "# Initial commit"
  38                echo "#"
  39                git-ls-files | sed 's/^/# New file: /'
  40                echo "#"
  41        ) > .editmsg
  42        PARENTS=""
  43else
  44        if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
  45                echo "#"
  46                echo "# It looks like your may be committing a MERGE."
  47                echo "# If this is not correct, please remove the file"
  48                echo "# $GIT_DIR/MERGE_HEAD"
  49                echo "# and try again"
  50                echo "#"
  51                PARENTS="-p HEAD -p MERGE_HEAD"
  52        elif test "$use_commit" != ""
  53        then
  54                pick_author_script='
  55                /^author /{
  56                        h
  57                        s/^author \([^<]*\) <[^>]*> .*$/\1/
  58                        s/'\''/'\''\'\'\''/g
  59                        s/.*/GIT_AUTHOR_NAME='\''&'\''/p
  60
  61                        g
  62                        s/^author [^<]* <\([^>]*\)> .*$/\1/
  63                        s/'\''/'\''\'\'\''/g
  64                        s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
  65
  66                        g
  67                        s/^author [^<]* <[^>]*> \(.*\)$/\1/
  68                        s/'\''/'\''\'\'\''/g
  69                        s/.*/GIT_AUTHOR_DATE='\''&'\''/p
  70
  71                        q
  72                }
  73                '
  74                set_author_env=`git-cat-file commit "$use_commit" |
  75                sed -ne "$pick_author_script"`
  76                eval "$set_author_env"
  77                export GIT_AUTHOR_NAME
  78                export GIT_AUTHOR_EMAIL
  79                export GIT_AUTHOR_DATE
  80                git-cat-file commit "$use_commit" |
  81                sed -e '1,/^$/d'
  82        fi >.editmsg
  83        git-status-script >>.editmsg
  84fi
  85if [ "$?" != "0" ]
  86then
  87        cat .editmsg
  88        rm .editmsg
  89        exit 1
  90fi
  91case "$use_commit" in
  92'')
  93        ${VISUAL:-${EDITOR:-vi}} .editmsg
  94        ;;
  95esac
  96grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
  97[ -s .cmitmsg ] && 
  98        tree=$(git-write-tree) &&
  99        commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
 100        echo $commit > "$GIT_DIR/HEAD" &&
 101        rm -f -- "$GIT_DIR/MERGE_HEAD"
 102ret="$?"
 103rm -f .cmitmsg .editmsg
 104exit "$ret"