@matheusbsbs / matheus-bagliano / commits / a159ca0cb7
Fork 0

Allow subcommand.color and color.subcommand color configuration

While adding colour to the branch command it was pointed out that a config option like "branch.color" conflicts with the pre-existing "branch.something" namespace used for specifying default merge urls and branches. The suggested solution was to flip the order of the components to "color.branch", which I did for colourising branch. This patch does the same thing for - git-log (color.diff) - git-status (color.status) - git-diff (color.diff) - pager (color.pager) I haven't removed the old config options; but they should probably be deprecated and eventually removed to prevent future namespace collisions. I've done this deprecation by changing the documentation for the config file to match the new names; and adding the "color.XXX" options to contrib/completion/git-completion.bash. Unfortunately git-svn reads "diff.color" and "pager.color"; which I don't like to change unilaterally. Signed-off-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Andy Parkins committed Dec 13, 2006 at 09:13 UTC a159ca0cb7e0acdd37cb066327dcb020d95602d0
6 files changed +15 -12
Documentation/config.txt
+6 -6
@@ -137,16 +137,16 @@ branch.<name>.merge::
137 this option, `git pull` defaults to merge the first refspec fetched.
138 Specify multiple values to get an octopus merge.
139
140 -pager.color::
140 +color.pager::
141 A boolean to enable/disable colored output when the pager is in
142 use (default is true).
143
144 -diff.color::
144 +color.diff::
145 When true (or `always`), always use colors in patch.
146 When false (or `never`), never. When set to `auto`, use
147 colors only when the output is to the terminal.
148
149 -diff.color.<slot>::
149 +color.diff.<slot>::
150 Use customized color for diff colorization. `<slot>`
151 specifies which part of the patch to use the specified
152 color, and is one of `plain` (context text), `meta`
@@ -271,19 +271,19 @@ showbranch.default::
271 The default set of branches for gitlink:git-show-branch[1].
272 See gitlink:git-show-branch[1].
273
274 -status.color::
274 +color.status::
275 A boolean to enable/disable color in the output of
276 gitlink:git-status[1]. May be set to `true` (or `always`),
277 `false` (or `never`) or `auto`, in which case colors are used
278 only when the output is to a terminal. Defaults to false.
279
280 -status.color.<slot>::
280 +color.status.<slot>::
281 Use customized color for status colorization. `<slot>` is
282 one of `header` (the header text of the status message),
283 `updated` (files which are updated but not committed),
284 `changed` (files which are changed but not updated in the index),
285 or `untracked` (files which are not tracked by git). The values of
286 - these variables may be specified as in diff.color.<slot>.
286 + these variables may be specified as in color.diff.<slot>.
287
288 tar.umask::
289 By default, gitlink:git-tar-tree[1] sets file and directories modes
builtin-log.c
+1 -1
@@ -118,7 +118,7 @@ static int git_format_config(const char *var, const char *value)
118 strcat(extra_headers, value);
119 return 0;
120 }
121 - if (!strcmp(var, "diff.color")) {
121 + if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
122 return 0;
123 }
124 return git_log_config(var, value);
config.c
+1 -1
@@ -314,7 +314,7 @@ int git_default_config(const char *var, const char *value)
314 return 0;
315 }
316
317 - if (!strcmp(var, "pager.color")) {
317 + if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
318 pager_use_color = git_config_bool(var,value);
319 return 0;
320 }
contrib/completion/git-completion.bash
+3
@@ -712,10 +712,13 @@ _git_repo_config ()
712 core.legacyHeaders
713 i18n.commitEncoding
714 diff.color
715 + color.diff
716 diff.renameLimit
717 diff.renames
718 pager.color
719 + color.pager
720 status.color
721 + color.status
722 log.showroot
723 show.difftree
724 showbranch.default
diff.c
+2 -2
@@ -60,7 +60,7 @@ int git_diff_ui_config(const char *var, const char *value)
60 diff_rename_limit_default = git_config_int(var, value);
61 return 0;
62 }
63 - if (!strcmp(var, "diff.color")) {
63 + if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
64 diff_use_color_default = git_config_colorbool(var, value);
65 return 0;
66 }
@@ -74,7 +74,7 @@ int git_diff_ui_config(const char *var, const char *value)
74 diff_detect_rename_default = DIFF_DETECT_RENAME;
75 return 0;
76 }
77 - if (!strncmp(var, "diff.color.", 11)) {
77 + if (!strncmp(var, "diff.color.", 11) || !strncmp(var, "color.diff.", 11)) {
78 int slot = parse_diff_color_slot(var, 11);
79 color_parse(value, var, diff_colors[slot]);
80 return 0;
wt-status.c
+2 -2
@@ -297,11 +297,11 @@ void wt_status_print(struct wt_status *s)
297
298 int git_status_config(const char *k, const char *v)
299 {
300 - if (!strcmp(k, "status.color")) {
300 + if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
301 wt_status_use_color = git_config_colorbool(k, v);
302 return 0;
303 }
304 - if (!strncmp(k, "status.color.", 13)) {
304 + if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status", 13)) {
305 int slot = parse_status_slot(k, 13);
306 color_parse(v, k, wt_status_colors[slot]);
307 }