{"thread":{"id":"43346","subject":"Re: [PATCH] Allow subcommand.color and color.subcommand color configuration","startedAt":"2006-12-13T09:13:28Z","lastAt":"2006-12-13T23:42:56Z","messageCount":4,"participants":["Junio C Hamano","Andy Parkins","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297858","messageId":"200612130913.28917.andyparkins@gmail.com","threadId":"43346","inReplyTo":null,"subject":"[PATCH] Allow subcommand.color and color.subcommand color configuration","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-13T09:13:28Z","receivedAt":"2006-12-13T09:13:28Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"While adding colour to the branch command it was pointed out that a\nconfig option like \"branch.color\" conflicts with the pre-existing\n\"branch.something\" namespace used for specifying default merge urls and\nbranches.  The suggested solution was to flip the order of the\ncomponents to \"color.branch\", which I did for colourising branch.\n\nThis patch does the same thing for\n  - git-log (color.diff)\n  - git-status (color.status)\n  - git-diff (color.diff)\n  - pager (color.pager)\n\nI haven't removed the old config options; but they should probably be\ndeprecated and eventually removed to prevent future namespace\ncollisions.  I've done this deprecation by changing the documentation\nfor the config file to match the new names; and adding the \"color.XXX\"\noptions to contrib/completion/git-completion.bash.\n\nUnfortunately git-svn reads \"diff.color\" and \"pager.color\"; which I\ndon't like to change unilaterally.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n Documentation/config.txt               |   12 ++++++------\n builtin-log.c                          |    2 +-\n config.c                               |    2 +-\n contrib/completion/git-completion.bash |    3 +++\n diff.c                                 |    4 ++--\n wt-status.c                            |    4 ++--\n 6 files changed, 15 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 9090762..9bdd824 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -130,16 +130,16 @@ branch.<name>.merge::\n \tWhen in branch <name>, it tells `git fetch` the default remote branch\n \tto be merged.\n \n-pager.color::\n+color.pager::\n \tA boolean to enable/disable colored output when the pager is in\n \tuse (default is true).\n \n-diff.color::\n+color.diff::\n \tWhen true (or `always`), always use colors in patch.\n \tWhen false (or `never`), never.  When set to `auto`, use\n \tcolors only when the output is to the terminal.\n \n-diff.color.<slot>::\n+color.diff.<slot>::\n \tUse customized color for diff colorization.  `<slot>`\n \tspecifies which part of the patch to use the specified\n \tcolor, and is one of `plain` (context text), `meta`\n@@ -264,19 +264,19 @@ showbranch.default::\n \tThe default set of branches for gitlink:git-show-branch[1].\n \tSee gitlink:git-show-branch[1].\n \n-status.color::\n+color.status::\n \tA boolean to enable/disable color in the output of\n \tgitlink:git-status[1]. May be set to `true` (or `always`),\n \t`false` (or `never`) or `auto`, in which case colors are used\n \tonly when the output is to a terminal. Defaults to false.\n \n-status.color.<slot>::\n+color.status.<slot>::\n \tUse customized color for status colorization. `<slot>` is\n \tone of `header` (the header text of the status message),\n \t`updated` (files which are updated but not committed),\n \t`changed` (files which are changed but not updated in the index),\n \tor `untracked` (files which are not tracked by git). The values of\n-\tthese variables may be specified as in diff.color.<slot>.\n+\tthese variables may be specified as in color.diff.<slot>.\n \n tar.umask::\n \tBy default, gitlink:git-tar-tree[1] sets file and directories modes\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 7acf5d3..6821a08 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -118,7 +118,7 @@ static int git_format_config(const char *var, const char *value)\n \t\tstrcat(extra_headers, value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n \t\treturn 0;\n \t}\n \treturn git_log_config(var, value);\ndiff --git a/config.c b/config.c\nindex 3cae390..06e7fdb 100644\n--- a/config.c\n+++ b/config.c\n@@ -314,7 +314,7 @@ int git_default_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n-\tif (!strcmp(var, \"pager.color\")) {\n+\tif (!strcmp(var, \"pager.color\") || !strcmp(car, \"color.pager\")) {\n \t\tpager_use_color = git_config_bool(var,value);\n \t\treturn 0;\n \t}\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 447ec20..9c4d23a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -712,10 +712,13 @@ _git_repo_config ()\n \t\tcore.legacyHeaders\n \t\ti18n.commitEncoding\n \t\tdiff.color\n+\t\tcolor.diff\n \t\tdiff.renameLimit\n \t\tdiff.renames\n \t\tpager.color\n+\t\tcolor.pager\n \t\tstatus.color\n+\t\tcolor.status\n \t\tlog.showroot\n \t\tshow.difftree\n \t\tshowbranch.default\ndiff --git a/diff.c b/diff.c\nindex 3315378..726b01e 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -60,7 +60,7 @@ int git_diff_ui_config(const char *var, const char *value)\n \t\tdiff_rename_limit_default = git_config_int(var, value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n \t\tdiff_use_color_default = git_config_colorbool(var, value);\n \t\treturn 0;\n \t}\n@@ -74,7 +74,7 @@ int git_diff_ui_config(const char *var, const char *value)\n \t\t\tdiff_detect_rename_default = DIFF_DETECT_RENAME;\n \t\treturn 0;\n \t}\n-\tif (!strncmp(var, \"diff.color.\", 11)) {\n+\tif (!strncmp(var, \"diff.color.\", 11) || !strncmp(var, \"color.diff.\", 11)) {\n \t\tint slot = parse_diff_color_slot(var, 11);\n \t\tcolor_parse(value, var, diff_colors[slot]);\n \t\treturn 0;\ndiff --git a/wt-status.c b/wt-status.c\nindex de1be5b..df582a0 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -297,11 +297,11 @@ void wt_status_print(struct wt_status *s)\n \n int git_status_config(const char *k, const char *v)\n {\n-\tif (!strcmp(k, \"status.color\")) {\n+\tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n \t\twt_status_use_color = git_config_colorbool(k, v);\n \t\treturn 0;\n \t}\n-\tif (!strncmp(k, \"status.color.\", 13)) {\n+\tif (!strncmp(k, \"status.color.\", 13) || !strncmp(k, \"color.status\", 13)) {\n \t\tint slot = parse_status_slot(k, 13);\n \t\tcolor_parse(v, k, wt_status_colors[slot]);\n \t}\n-- \n1.4.4.1.g3ece-dirty\n"},{"id":"294433","messageId":"7vodq7e90z.fsf@assigned-by-dhcp.cox.net","threadId":"43346","inReplyTo":"200612130913.28917.andyparkins@gmail.com","subject":"Re: [PATCH] Allow subcommand.color and color.subcommand color configuration","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-13T22:16:44Z","receivedAt":"2006-12-13T22:16:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> While adding colour to the branch command it was pointed out that a\n> config option like \"branch.color\" conflicts with the pre-existing\n> \"branch.something\" namespace used for specifying default merge urls and\n> branches.  The suggested solution was to flip the order of the\n> components to \"color.branch\", which I did for colourising branch.\n> ...\n> Unfortunately git-svn reads \"diff.color\" and \"pager.color\"; which I\n> don't like to change unilaterally.\n\nI think doing the same makes sense.  Something like this?\n\n-- >8 --\ngit-svn: allow both diff.color and color.diff\n\nThe list concensus is to group color related configuration under\n\"color.*\" so let's be consistent.\n\nInspired by Andy Parkins's patch to do the same for diff/log\nfamily.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/git-svn.perl b/git-svn.perl\nindex ec92b44..2893e3b 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -925,19 +925,38 @@ sub cmt_showable {\n \n sub log_use_color {\n \treturn 1 if $_color;\n-\tmy $dc;\n-\tchomp($dc = `git-repo-config --get diff.color`);\n+\tmy ($dc, $dcvar);\n+\t$dcvar = 'color.diff'\n+\t$dc = `git-repo-config --get $dcvar`;\n+\tif ($dc eq '') {\n+\t\t# nothing at all; fallback to \"diff.color\"\n+\t\t$dcvar = 'diff.color';\n+\t\t$dc = `git-repo-config --get $dcvar`;\n+\t}\n+\tchomp($dc);\n \tif ($dc eq 'auto') {\n-\t\tif (-t *STDOUT || (defined $_pager &&\n-\t\t    `git-repo-config --bool --get pager.color` !~ /^false/)) {\n+\t\tmy $pc;\n+\t\t$pc = `git-repo-config --get color.pager`;\n+\t\tif ($pc eq '') {\n+\t\t\t# does not have it -- fallback to pager.color\n+\t\t\t$pc = `git-repo-config --bool --get pager.color`;\n+\t\t}\n+\t\telse {\n+\t\t\t$pc = `git-repo-config --bool --get color.pager`;\n+\t\t\tif ($?) {\n+\t\t\t\t$pc = 'false';\n+\t\t\t}\n+\t\t}\n+\t\tchomp($pc);\n+\t\tif (-t *STDOUT || (defined $_pager && $pc eq 'true') {\n \t\t\treturn ($ENV{TERM} && $ENV{TERM} ne 'dumb');\n \t\t}\n \t\treturn 0;\n \t}\n \treturn 0 if $dc eq 'never';\n \treturn 1 if $dc eq 'always';\n-\tchomp($dc = `git-repo-config --bool --get diff.color`);\n-\t$dc eq 'true';\n+\tchomp($dc = `git-repo-config --bool --get $dcvar`);\n+\treturn ($dc eq 'true');\n }\n \n sub git_svn_log_cmd {\n"},{"id":"295628","messageId":"200612132252.51696.andyparkins@gmail.com","threadId":"43346","inReplyTo":"7vodq7e90z.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Allow subcommand.color and color.subcommand color configuration","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-13T22:52:50Z","receivedAt":"2006-12-13T22:52:50Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Wednesday 2006, December 13 22:16, Junio C Hamano wrote:\n\n> I think doing the same makes sense.  Something like this?\n\nPerfect - yes that is the solution.\n\n\nAndy\n\n-- \nDr Andrew Parkins, M Eng (Hons), AMIEE\n"},{"id":"296302","messageId":"20061213234256.GA10423@soma","threadId":"43346","inReplyTo":"7vodq7e90z.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Allow subcommand.color and color.subcommand color configuration","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-12-13T23:42:56Z","receivedAt":"2006-12-13T23:42:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Andy Parkins <andyparkins@gmail.com> writes:\n> \n> > While adding colour to the branch command it was pointed out that a\n> > config option like \"branch.color\" conflicts with the pre-existing\n> > \"branch.something\" namespace used for specifying default merge urls and\n> > branches.  The suggested solution was to flip the order of the\n> > components to \"color.branch\", which I did for colourising branch.\n> > ...\n> > Unfortunately git-svn reads \"diff.color\" and \"pager.color\"; which I\n> > don't like to change unilaterally.\n> \n> I think doing the same makes sense.  Something like this?\n\nIt works great for me after I fixed some syntax errors (patch below).\n\n> -- >8 --\n> git-svn: allow both diff.color and color.diff\n> \n> The list concensus is to group color related configuration under\n> \"color.*\" so let's be consistent.\n> \n> Inspired by Andy Parkins's patch to do the same for diff/log\n> family.\n> \n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net> (with the following\nfixes of course :)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 2893e3b..73ab8d8 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -926,7 +926,7 @@ sub cmt_showable {\n sub log_use_color {\n \treturn 1 if $_color;\n \tmy ($dc, $dcvar);\n-\t$dcvar = 'color.diff'\n+\t$dcvar = 'color.diff';\n \t$dc = `git-repo-config --get $dcvar`;\n \tif ($dc eq '') {\n \t\t# nothing at all; fallback to \"diff.color\"\n@@ -948,7 +948,7 @@ sub log_use_color {\n \t\t\t}\n \t\t}\n \t\tchomp($pc);\n-\t\tif (-t *STDOUT || (defined $_pager && $pc eq 'true') {\n+\t\tif (-t *STDOUT || (defined $_pager && $pc eq 'true')) {\n \t\t\treturn ($ENV{TERM} && $ENV{TERM} ne 'dumb');\n \t\t}\n \t\treturn 0;\n\n-- \n"}]}