Write .editmsg in GIT_DIR to avoid being in git-status.

It appears in the git-status output during a git-commit if you have
something in info/exclude.

Also for .cmitmsg and .cmitchk to make git-commit work
in read-only working trees.

[jc: while we are at it, I removed the use of .cmitchk temporary
     file which was not necessary, and renamed them -- they are out
     of way now and do not have to be dotfiles anymore.]

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Santi_Béjar 2005-10-09 17:30:19 -07:00 committed by Junio C Hamano
parent f7c153431b
commit f8e2c54c9a

View File

@ -129,7 +129,7 @@ then
elif test "$use_commit" != "" elif test "$use_commit" != ""
then then
git-cat-file commit "$use_commit" | sed -e '1,/^$/d' git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
fi | git-stripspace >.editmsg fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
case "$signoff" in case "$signoff" in
t) t)
@ -139,7 +139,7 @@ t)
s/>.*/>/ s/>.*/>/
s/^/Signed-off-by: / s/^/Signed-off-by: /
' '
} >>.editmsg } >>"$GIT_DIR"/COMMIT_EDITMSG
;; ;;
esac esac
@ -153,7 +153,7 @@ if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
echo "# $GIT_DIR/MERGE_HEAD" echo "# $GIT_DIR/MERGE_HEAD"
echo "# and try again" echo "# and try again"
echo "#" echo "#"
fi >>.editmsg fi >>"$GIT_DIR"/COMMIT_EDITMSG
PARENTS="-p HEAD" PARENTS="-p HEAD"
if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1 if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
@ -197,16 +197,16 @@ else
fi fi
PARENTS="" PARENTS=""
fi fi
git-status >>.editmsg git-status >>"$GIT_DIR"/COMMIT_EDITMSG
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ] if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
then then
rm -f .editmsg rm -f "$GIT_DIR/COMMIT_EDITMSG"
git-status git-status
exit 1 exit 1
fi fi
case "$no_edit" in case "$no_edit" in
'') '')
${VISUAL:-${EDITOR:-vi}} .editmsg ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG"
;; ;;
esac esac
@ -214,16 +214,20 @@ case "$verify" in
t) t)
if test -x "$GIT_DIR"/hooks/commit-msg if test -x "$GIT_DIR"/hooks/commit-msg
then then
"$GIT_DIR"/hooks/commit-msg .editmsg || exit "$GIT_DIR"/hooks/commit-msg "$GIT_DIR"/COMMIT_EDITMSG || exit
fi fi
esac esac
grep -v '^#' < .editmsg | git-stripspace > .cmitmsg grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG |
grep -v -i '^Signed-off-by' .cmitmsg >.cmitchk git-stripspace > "$GIT_DIR"/COMMIT_MSG
if test -s .cmitchk
if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
git-stripspace |
wc -l` &&
test 0 -lt $cnt
then then
tree=$(git-write-tree) && tree=$(git-write-tree) &&
commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) && commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
git-update-ref HEAD $commit $current && git-update-ref HEAD $commit $current &&
rm -f -- "$GIT_DIR/MERGE_HEAD" rm -f -- "$GIT_DIR/MERGE_HEAD"
else else
@ -231,7 +235,7 @@ else
false false
fi fi
ret="$?" ret="$?"
rm -f .cmitmsg .editmsg .cmitchk rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG"
if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0 if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
then then