From: Junio C Hamano Date: Tue, 17 Oct 2017 06:08:31 +0000 (+0900) Subject: Merge branch 'jk/ui-color-always-to-auto-maint' (early part) into jk/ref-filter-colors-fix-maint X-Git-Tag: v2.15.0-rc2~7^2~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/433d62fea95fccdd57a81641618f61544d699126?ds=inline;hp=-c Merge branch 'jk/ui-color-always-to-auto-maint' (early part) into jk/ref-filter-colors-fix-maint * 'jk/ui-color-always-to-auto-maint' (early part): color: make "always" the same as "auto" in config provide --color option for all ref-filter users t3205: use --color instead of color.branch=always t3203: drop "always" color test t6006: drop "always" color config tests t7502: use diff.noprefix for --verbose test t7508: use test_terminal for color output t3701: use test-terminal to collect color output t4015: prefer --color to -c color.diff=always test-terminal: set TERM=vt100 --- 433d62fea95fccdd57a81641618f61544d699126 diff --combined Documentation/config.txt index 2271809d90,cb0f951ddc..517ee48ba6 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -216,15 -216,15 +216,15 @@@ boolean: synonyms are accepted for 'true' and 'false'; these are all case-insensitive. - true;; Boolean true can be spelled as `yes`, `on`, `true`, - or `1`. Also, a variable defined without `= ` + true;; Boolean true literals are `yes`, `on`, `true`, + and `1`. Also, a variable defined without `= ` is taken as true. - false;; Boolean false can be spelled as `no`, `off`, - `false`, or `0`. + false;; Boolean false literals are `no`, `off`, `false`, + `0` and the empty string. + When converting value to the canonical form using `--bool` type -specifier; 'git config' will ensure that the output is "true" or +specifier, 'git config' will ensure that the output is "true" or "false" (spelled in lowercase). integer:: @@@ -1052,10 -1052,10 +1052,10 @@@ clean.requireForce: color.branch:: A boolean to enable/disable color in the output of - linkgit:git-branch[1]. May be set to `always`, - `false` (or `never`) or `auto` (or `true`), in which case colors are used - only when the output is to a terminal. If unset, then the - value of `color.ui` is used (`auto` by default). + linkgit:git-branch[1]. May be set to `false` (or `never`) to + disable color entirely, `auto` (or `true` or `always`) in which + case colors are used only when the output is to a terminal. If + unset, then the value of `color.ui` is used (`auto` by default). color.branch.:: Use customized color for branch coloration. `` is one of @@@ -1066,12 -1066,11 +1066,11 @@@ color.diff:: Whether to use ANSI escape sequences to add color to patches. - If this is set to `always`, linkgit:git-diff[1], + If this is set to `true` or `auto`, linkgit:git-diff[1], linkgit:git-log[1], and linkgit:git-show[1] will use color - for all patches. If it is set to `true` or `auto`, those - commands will only use color when output is to the terminal. - If unset, then the value of `color.ui` is used (`auto` by - default). + when output is to the terminal. The value `always` is a + historical synonym for `auto`. If unset, then the value of + `color.ui` is used (`auto` by default). + This does not affect linkgit:git-format-patch[1] or the 'git-diff-{asterisk}' plumbing commands. Can be overridden on the @@@ -1124,12 -1123,12 +1123,12 @@@ color.grep.: -- color.interactive:: - When set to `always`, always use colors for interactive prompts + When set to `true` or `auto`, use colors for interactive prompts and displays (such as those used by "git-add --interactive" and - "git-clean --interactive"). When false (or `never`), never. - When set to `true` or `auto`, use colors only when the output is - to the terminal. If unset, then the value of `color.ui` is - used (`auto` by default). + "git-clean --interactive") when the output is to the terminal. + When false (or `never`), never show colors. The value `always` + is a historical synonym for `auto`. If unset, then the value of + `color.ui` is used (`auto` by default). color.interactive.:: Use customized color for 'git add --interactive' and 'git clean @@@ -1176,10 -1175,10 +1175,10 @@@ color.ui: configuration to set a default for the `--color` option. Set it to `false` or `never` if you prefer Git commands not to use color unless enabled explicitly with some other configuration - or the `--color` option. Set it to `always` if you want all - output not intended for machine consumption to use color, to - `true` or `auto` (this is the default since Git 1.8.4) if you - want such output to use color when written to the terminal. + or the `--color` option. Set it to `true` or `auto` to enable + color when output is written to the terminal (this is also the + default since Git 1.8.4). The value `always` is a historical + synonym for `auto`. column.ui:: Specify whether supported commands should output in columns. @@@ -2912,8 -2911,8 +2911,8 @@@ sendemail.smtpsslcertpath: sendemail..*:: Identity-specific versions of the 'sendemail.*' parameters - found below, taking precedence over those when the this - identity is selected, through command-line or + found below, taking precedence over those when this + identity is selected, through either the command-line or `sendemail.identity`. sendemail.aliasesFile:: diff --combined Documentation/git-for-each-ref.txt index bb370c9c7b,b92ebd0cd9..8bbeeba291 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@@ -38,12 -38,11 +38,12 @@@ OPTION key. :: - A string that interpolates `%(fieldname)` from the - object pointed at by a ref being shown. If `fieldname` + A string that interpolates `%(fieldname)` from a ref being shown + and the object it points at. If `fieldname` is prefixed with an asterisk (`*`) and the ref points - at a tag object, the value for the field in the object - tag refers is used. When unspecified, defaults to + at a tag object, use the value for the field in the object + which the tag object refers to (instead of the field in the tag object). + When unspecified, `` defaults to `%(objectname) SPC %(objecttype) TAB %(refname)`. It also interpolates `%%` to `%`, and `%xx` where `xx` are hex digits interpolates to character with hex code @@@ -56,6 -55,11 +56,11 @@@ literally, in the latter case matching completely or from the beginning up to a slash. + --color[=]: + Respect any colors specified in the `--format` option. The + `` field must be one of `always`, `never`, or `auto` (if + `` is absent, behave as if `always` was given). + --shell:: --perl:: --python:: diff --combined Documentation/git-tag.txt index 543fb425ee,a1399a78a0..e130fa0f47 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@@ -115,6 -115,11 +115,11 @@@ options for details variable if it exists, or lexicographic order otherwise. See linkgit:git-config[1]. + --color[=]: + Respect any colors specified in the `--format` option. The + `` field must be one of `always`, `never`, or `auto` (if + `` is absent, behave as if `always` was given). + -i:: --ignore-case:: Sorting and filtering tags are case insensitive. @@@ -188,8 -193,8 +193,8 @@@ This option is only applicable when lis Defaults to HEAD. :: - A string that interpolates `%(fieldname)` from the object - pointed at by a ref being shown. The format is the same as + A string that interpolates `%(fieldname)` from a tag ref being shown + and the object it points at. The format is the same as that of linkgit:git-for-each-ref[1]. When unspecified, defaults to `%(refname:strip=2)`. @@@ -205,9 -210,6 +210,9 @@@ it in the repository configuration as f signingKey = ------------------------------------- +`pager.tag` is only respected when listing tags, i.e., when `-l` is +used or implied. The default is to use a pager. +See linkgit:git-config[1]. DISCUSSION ---------- diff --combined builtin/tag.c index 7a70d5a9bb,b9d1a13af5..fe0a8ab944 --- a/builtin/tag.c +++ b/builtin/tag.c @@@ -411,6 -411,7 +411,7 @@@ int cmd_tag(int argc, const char **argv }, OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")), + OPT__COLOR(&format.use_color, N_("respect format colors")), OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")), OPT_END() }; @@@ -440,9 -441,6 +441,9 @@@ cmdmode = 'l'; } + if (cmdmode == 'l') + setup_auto_pager("tag", 1); + if ((create_tag_object || force) && (cmdmode != 0)) usage_with_options(git_tag_usage, options); diff --combined t/t4202-log.sh index 36d120c969,62f9d94fa3..8f155da7a5 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@@ -750,7 -750,7 +750,7 @@@ test_expect_success 'log.decorate confi ' test_expect_success TTY 'log output on a TTY' ' - git log --oneline --decorate >expect.short && + git log --color --oneline --decorate >expect.short && test_terminal git log --oneline >actual && test_cmp expect.short actual @@@ -1523,12 -1523,6 +1523,12 @@@ test_expect_success 'log diagnoses bogu test_i18ngrep broken stderr ' +test_expect_success 'log does not default to HEAD when rev input is given' ' + >expect && + git log --branches=does-not-exist >actual && + test_cmp expect actual +' + test_expect_success 'set up --source tests' ' git checkout --orphan source-a && test_commit one && diff --combined t/t7004-tag.sh index dbcd6f623c,f5547371a3..b90db1bf74 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@@ -1888,7 -1888,7 +1888,7 @@@ EOF run_with_limited_stack git tag --contains HEAD >actual && test_cmp expect actual && run_with_limited_stack git tag --no-contains HEAD >actual && - test_line_count ">" 10 actual + test_line_count "-gt" 10 actual ' test_expect_success '--format should list tags as per format given' ' @@@ -1914,13 -1914,13 +1914,13 @@@ test_expect_success '%(color) omitted w ' test_expect_success TTY '%(color) present with tty' ' - test_terminal env TERM=vt100 git tag $color_args >actual.raw && + test_terminal git tag $color_args >actual.raw && test_decode_color actual && test_cmp expect.color actual ' - test_expect_success 'color.ui=always overrides auto-color' ' - git -c color.ui=always tag $color_args >actual.raw && + test_expect_success '--color overrides auto-color' ' + git tag --color $color_args >actual.raw && test_decode_color actual && test_cmp expect.color actual ' diff --combined t/t7006-pager.sh index 9128ec5acd,20caa3f095..f0f1abd1c2 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@@ -134,86 -134,6 +134,86 @@@ test_expect_success TTY 'configuration } ' +test_expect_success TTY 'git tag -l defaults to paging' ' + rm -f paginated.out && + test_terminal git tag -l && + test -e paginated.out +' + +test_expect_success TTY 'git tag -l respects pager.tag' ' + rm -f paginated.out && + test_terminal git -c pager.tag=false tag -l && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag -l respects --no-pager' ' + rm -f paginated.out && + test_terminal git -c pager.tag --no-pager tag -l && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag with no args defaults to paging' ' + # no args implies -l so this should page like -l + rm -f paginated.out && + test_terminal git tag && + test -e paginated.out +' + +test_expect_success TTY 'git tag with no args respects pager.tag' ' + # no args implies -l so this should page like -l + rm -f paginated.out && + test_terminal git -c pager.tag=false tag && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag --contains defaults to paging' ' + # --contains implies -l so this should page like -l + rm -f paginated.out && + test_terminal git tag --contains && + test -e paginated.out +' + +test_expect_success TTY 'git tag --contains respects pager.tag' ' + # --contains implies -l so this should page like -l + rm -f paginated.out && + test_terminal git -c pager.tag=false tag --contains && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag -a defaults to not paging' ' + test_when_finished "git tag -d newtag" && + rm -f paginated.out && + test_terminal git tag -am message newtag && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag -a ignores pager.tag' ' + test_when_finished "git tag -d newtag" && + rm -f paginated.out && + test_terminal git -c pager.tag tag -am message newtag && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag -a respects --paginate' ' + test_when_finished "git tag -d newtag" && + rm -f paginated.out && + test_terminal git --paginate tag -am message newtag && + test -e paginated.out +' + +test_expect_success TTY 'git tag as alias ignores pager.tag with -a' ' + test_when_finished "git tag -d newtag" && + rm -f paginated.out && + test_terminal git -c pager.tag -c alias.t=tag t -am message newtag && + ! test -e paginated.out +' + +test_expect_success TTY 'git tag as alias respects pager.tag with -l' ' + rm -f paginated.out && + test_terminal git -c pager.tag=false -c alias.t=tag t -l && + ! test -e paginated.out +' + # A colored commit log will begin with an appropriate ANSI escape # for the first color; the text "commit" comes later. colorful() { @@@ -239,7 -159,7 +239,7 @@@ test_expect_success 'no color when stdo test_expect_success TTY 'color when writing to a pager' ' rm -f paginated.out && test_config color.ui auto && - test_terminal env TERM=vt100 git log && + test_terminal git log && colorful paginated.out ' @@@ -247,7 -167,7 +247,7 @@@ test_expect_success TTY 'colors are sup rm -f paginated.out && test_config color.ui auto && test_config color.pager false && - test_terminal env TERM=vt100 git log && + test_terminal git log && ! colorful paginated.out ' @@@ -266,7 -186,7 +266,7 @@@ test_expect_success 'color when writin test_expect_success TTY 'colors are sent to pager for external commands' ' test_config alias.externallog "!git log" && test_config color.ui auto && - test_terminal env TERM=vt100 git -p externallog && + test_terminal git -p externallog && colorful paginated.out '