summaryrefslogtreecommitdiff
path: root/git-commit-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-19 19:57:01 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-19 19:57:01 -0700
commit170241b7d1437e082c13a6f6b812eb827a7d48e0 (patch)
tree7921202726b96c4af972f752b7a96471bbfb04d3 /git-commit-script
parent55a716cc8c93fd2eb161ae17f316ee01e8061be6 (diff)
downloadgit-170241b7d1437e082c13a6f6b812eb827a7d48e0.tar.gz
Make "git commit" clean up after itself
Noted by Jeff.
Diffstat (limited to 'git-commit-script')
-rwxr-xr-xgit-commit-script14
1 files changed, 9 insertions, 5 deletions
diff --git a/git-commit-script b/git-commit-script
index f88a51a43c..5e5c0ccb3a 100755
--- a/git-commit-script
+++ b/git-commit-script
@@ -33,12 +33,16 @@ fi
if [ "$?" != "0" ]
then
cat .editmsg
+ rm .editmsg
exit 1
fi
${VISUAL:-${EDITOR:-vi}} .editmsg
grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
-[ -s .cmitmsg ] || exit 1
-tree=$(git-write-tree) || exit 1
-commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) || exit 1
-echo $commit > $GIT_DIR/HEAD
-rm -f -- $GIT_DIR/MERGE_HEAD
+[ -s .cmitmsg ] &&
+ tree=$(git-write-tree) &&
+ commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
+ echo $commit > $GIT_DIR/HEAD &&
+ rm -f -- $GIT_DIR/MERGE_HEAD
+ret="$?"
+rm -f .cmitmsg .editmsg
+exit "$ret"