Don't colorize the refs with git log --pretty when --no-color is specified

一个人想着一个人 提交于 2019-12-06 06:03:06

can't figure out how to get it to respect the --no-color option.
If I set it to %C(auto), the colors show all the time.

This will be fixed in git 2.9.x+ (Q3 2016)

See commit b15a3e0 (27 May 2016) by Edward Thomson (ethomson).
(Merged by Junio C Hamano -- gitster -- in commit 1b3d14c, 20 Jun 2016)

format_commit_message: honor color=auto for %C(auto)

git-log(1) documents that when specifying the %C(auto) format placeholder will "turn on auto coloring on the next %placeholders until the color is switched again."

However, when %C(auto) is used, the present implementation will turn colors on unconditionally (even if the color configuration is turned off for the current context - for example, --no-color was specified or the color is auto and the output is not a tty).

Update format_commit_one to examine the current context when a format string of %C(auto) is specified, which ensures that we will not unconditionally write colors.
This brings that behavior in line with the behavior of %C(auto,<colorname>), and allows the user the ability to specify that color should be displayed only when the output is a tty.

This is what you see with git-for-windows 2.9.0

But with a more recent 2.9.x+ git version, --no-color does work:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!