]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Allow subcommand.color and color.subcommand color configuration
authorAndy Parkins <andyparkins@gmail.com>
Wed, 13 Dec 2006 09:13:28 +0000 (09:13 +0000)
committerJunio C Hamano <junkio@cox.net>
Wed, 13 Dec 2006 09:47:36 +0000 (01:47 -0800)
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>
Documentation/config.txt
builtin-log.c
config.c
contrib/completion/git-completion.bash
diff.c
wt-status.c

index 21ec55797b8a17f9905ab0a667661439fbf50adb..f5a552ee8722dc0e18265164fd6a6b344d691d57 100644 (file)
@@ -137,16 +137,16 @@ branch.<name>.merge::
        this option, `git pull` defaults to merge the first refspec fetched.
        Specify multiple values to get an octopus merge.
 
-pager.color::
+color.pager::
        A boolean to enable/disable colored output when the pager is in
        use (default is true).
 
-diff.color::
+color.diff::
        When true (or `always`), always use colors in patch.
        When false (or `never`), never.  When set to `auto`, use
        colors only when the output is to the terminal.
 
-diff.color.<slot>::
+color.diff.<slot>::
        Use customized color for diff colorization.  `<slot>`
        specifies which part of the patch to use the specified
        color, and is one of `plain` (context text), `meta`
@@ -271,19 +271,19 @@ showbranch.default::
        The default set of branches for gitlink:git-show-branch[1].
        See gitlink:git-show-branch[1].
 
-status.color::
+color.status::
        A boolean to enable/disable color in the output of
        gitlink:git-status[1]. May be set to `true` (or `always`),
        `false` (or `never`) or `auto`, in which case colors are used
        only when the output is to a terminal. Defaults to false.
 
-status.color.<slot>::
+color.status.<slot>::
        Use customized color for status colorization. `<slot>` is
        one of `header` (the header text of the status message),
        `updated` (files which are updated but not committed),
        `changed` (files which are changed but not updated in the index),
        or `untracked` (files which are not tracked by git). The values of
-       these variables may be specified as in diff.color.<slot>.
+       these variables may be specified as in color.diff.<slot>.
 
 tar.umask::
        By default, gitlink:git-tar-tree[1] sets file and directories modes
index 7acf5d3b0c3393ee700e084470824bb7fd7cf88a..6821a08442603ba28ee2190a9f602f3d8d0f43f3 100644 (file)
@@ -118,7 +118,7 @@ static int git_format_config(const char *var, const char *value)
                strcat(extra_headers, value);
                return 0;
        }
-       if (!strcmp(var, "diff.color")) {
+       if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
                return 0;
        }
        return git_log_config(var, value);
index 3cae3901aa9b50e8d04a8ce2633a1a1ef8ed0f6c..1bdef44a3ad315ecc4cdfa879e9c0881bd82722b 100644 (file)
--- a/config.c
+++ b/config.c
@@ -314,7 +314,7 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
-       if (!strcmp(var, "pager.color")) {
+       if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
                pager_use_color = git_config_bool(var,value);
                return 0;
        }
index 447ec20467f667ec4ad4260e68bc35904b2b65ce..9c4d23a23c899798613978c1766d08a80ced6f2e 100755 (executable)
@@ -712,10 +712,13 @@ _git_repo_config ()
                core.legacyHeaders
                i18n.commitEncoding
                diff.color
+               color.diff
                diff.renameLimit
                diff.renames
                pager.color
+               color.pager
                status.color
+               color.status
                log.showroot
                show.difftree
                showbranch.default
diff --git a/diff.c b/diff.c
index 33153787b8117396cf906e69e656849ac04f3257..726b01e75e9b9fb7c5e161eb466a1aea335a25c3 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -60,7 +60,7 @@ int git_diff_ui_config(const char *var, const char *value)
                diff_rename_limit_default = git_config_int(var, value);
                return 0;
        }
-       if (!strcmp(var, "diff.color")) {
+       if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
                diff_use_color_default = git_config_colorbool(var, value);
                return 0;
        }
@@ -74,7 +74,7 @@ int git_diff_ui_config(const char *var, const char *value)
                        diff_detect_rename_default = DIFF_DETECT_RENAME;
                return 0;
        }
-       if (!strncmp(var, "diff.color.", 11)) {
+       if (!strncmp(var, "diff.color.", 11) || !strncmp(var, "color.diff.", 11)) {
                int slot = parse_diff_color_slot(var, 11);
                color_parse(value, var, diff_colors[slot]);
                return 0;
index de1be5bc66de634e41c7ef3dee08209631249e13..df582a03ef37284496b29a83b3e0bc798e6e4664 100644 (file)
@@ -297,11 +297,11 @@ void wt_status_print(struct wt_status *s)
 
 int git_status_config(const char *k, const char *v)
 {
-       if (!strcmp(k, "status.color")) {
+       if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
                wt_status_use_color = git_config_colorbool(k, v);
                return 0;
        }
-       if (!strncmp(k, "status.color.", 13)) {
+       if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status", 13)) {
                int slot = parse_status_slot(k, 13);
                color_parse(v, k, wt_status_colors[slot]);
        }