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>
Santi_Béjar committed
Oct 9, 2005 at 17:30 UTC
f8e2c54c9a17af3319e96db1d9e97ace36ae6831
1 file changed
+16
-12
git-commit.sh
+16
-12
@@ -129,7 +129,7 @@ then
129
elif test "$use_commit" != ""
130
then
131
git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
132
-fi | git-stripspace >.editmsg
132
+fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
133
134
case "$signoff" in
135
t)
@@ -139,7 +139,7 @@ t)
139
s/>.*/>/
140
s/^/Signed-off-by: /
141
'
142
- } >>.editmsg
142
+ } >>"$GIT_DIR"/COMMIT_EDITMSG
143
;;
144
esac
145
@@ -153,7 +153,7 @@ if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
153
echo "# $GIT_DIR/MERGE_HEAD"
154
echo "# and try again"
155
echo "#"
156
-fi >>.editmsg
156
+fi >>"$GIT_DIR"/COMMIT_EDITMSG
157
158
PARENTS="-p HEAD"
159
if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
@@ -197,16 +197,16 @@ else
197
fi
198
PARENTS=""
199
fi
200
-git-status >>.editmsg
200
+git-status >>"$GIT_DIR"/COMMIT_EDITMSG
201
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
202
then
203
- rm -f .editmsg
203
+ rm -f "$GIT_DIR/COMMIT_EDITMSG"
204
git-status
205
exit 1
206
fi
207
case "$no_edit" in
208
'')
209
- ${VISUAL:-${EDITOR:-vi}} .editmsg
209
+ ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG"
210
;;
211
esac
212
@@ -214,16 +214,20 @@ case "$verify" in
214
t)
215
if test -x "$GIT_DIR"/hooks/commit-msg
216
then
217
- "$GIT_DIR"/hooks/commit-msg .editmsg || exit
217
+ "$GIT_DIR"/hooks/commit-msg "$GIT_DIR"/COMMIT_EDITMSG || exit
218
fi
219
esac
220
221
-grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
222
-grep -v -i '^Signed-off-by' .cmitmsg >.cmitchk
223
-if test -s .cmitchk
221
+grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG |
222
+git-stripspace > "$GIT_DIR"/COMMIT_MSG
223
+
224
+if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
225
+ git-stripspace |
226
+ wc -l` &&
227
+ test 0 -lt $cnt
228
then
229
tree=$(git-write-tree) &&
226
- commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
230
+ commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
231
git-update-ref HEAD $commit $current &&
232
rm -f -- "$GIT_DIR/MERGE_HEAD"
233
else
@@ -231,7 +235,7 @@ else
235
false
236
fi
237
ret="$?"
234
-rm -f .cmitmsg .editmsg .cmitchk
238
+rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG"
239
240
if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
241
then