git-commit-scripton commit [PATCH] local-pull: implement fetch_ref() (f5ab6cc)
   1#!/bin/sh
   2: ${GIT_DIR=.git}
   3if [ ! -d $GIT_DIR ]; then
   4        echo Not a git directory 1>&2
   5        exit 1
   6fi
   7git-update-cache -q --refresh -- "$@" || exit 1
   8PARENTS="-p HEAD"
   9if [ ! -r $GIT_DIR/HEAD ]; then
  10        if [ -z "$(git-ls-files)" ]; then
  11                echo Nothing to commit 1>&2
  12                exit 1
  13        fi
  14        (
  15                echo "#"
  16                echo "# Initial commit"
  17                echo "#"
  18                git-ls-files | sed 's/^/# New file: /'
  19                echo "#"
  20        ) > .editmsg
  21        PARENTS=""
  22else
  23        if [ -f $GIT_DIR/MERGE_HEAD ]; then
  24                echo "#"
  25                echo "# It looks like your may be committing a MERGE."
  26                echo "# If this is not correct, please remove the file"
  27                echo "# $GIT_DIR/MERGE_HEAD"
  28                echo "# and try again"
  29                echo "#"
  30                PARENTS="-p HEAD -p MERGE_HEAD"
  31        fi > .editmsg
  32        git-status-script >> .editmsg
  33fi
  34if [ "$?" != "0" ]
  35then
  36        cat .editmsg
  37        rm .editmsg
  38        exit 1
  39fi
  40${VISUAL:-${EDITOR:-vi}} .editmsg
  41grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
  42[ -s .cmitmsg ] && 
  43        tree=$(git-write-tree) &&
  44        commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
  45        echo $commit > $GIT_DIR/HEAD &&
  46        rm -f -- $GIT_DIR/MERGE_HEAD
  47ret="$?"
  48rm -f .cmitmsg .editmsg
  49exit "$ret"