Skip to content

Commit 09b0d9d

Browse files
wheegitster
authored andcommitted
When nothing to git-commit, honor the git-status color setting.
Instead of disabling color all of the time during a git-commit, allow the user's config preference in the situation where there is nothing to commit. In this situation, the status is printed to the terminal and not sent to COMMIT_EDITMSG, so honoring the status color setting is expected. Signed-off-by: Brian Hetro <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 67aca45 commit 09b0d9d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

git-commit.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ run_status () {
4949
export GIT_INDEX_FILE
5050
fi
5151

52-
case "$status_only" in
53-
t) color= ;;
54-
*) color=--nocolor ;;
55-
esac
52+
if test "$status_only" = "t" -o "$use_status_color" = "t"; then
53+
color=
54+
else
55+
color=--nocolor
56+
fi
5657
git runstatus ${color} \
5758
${verbose:+--verbose} \
5859
${amend:+--amend} \
@@ -556,6 +557,7 @@ fi
556557
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
557558
then
558559
rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
560+
use_status_color=t
559561
run_status
560562
exit 1
561563
fi

0 commit comments

Comments
 (0)