OSDN Git Service

status: introduce status.branch to enable --branch by default
authorJorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>
Tue, 11 Jun 2013 13:34:05 +0000 (15:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 16 Jun 2013 05:15:28 +0000 (22:15 -0700)
Some people often run 'git status -b'.
The config variable status.branch allows to set it by default.

Signed-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>
Signed-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>
Reviewed-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
builtin/commit.c
t/t7508-status.sh

index 1983bf7..ecdcd6d 100644 (file)
@@ -2070,6 +2070,10 @@ status.short::
        Set to true to enable --short by default in linkgit:git-status[1].
        The option --no-short takes precedence over this variable.
 
+status.branch::
+       Set to true to enable --branch by default in linkgit:git-status[1].
+       The option --no-branch takes precedence over this variable.
+
 status.showUntrackedFiles::
        By default, linkgit:git-status[1] and linkgit:git-commit[1] show
        files which are not currently tracked by Git. Directories which
index b2f41de..d6c8e20 100644 (file)
@@ -1117,6 +1117,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
                        status_format = STATUS_FORMAT_NONE;
                return 0;
        }
+       if (!strcmp(k, "status.branch")) {
+               s->show_branch = git_config_bool(k, v);
+               return 0;
+       }
        if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
                s->use_color = git_config_colorbool(k, v);
                return 0;
index 33cadd0..498332c 100755 (executable)
@@ -1361,6 +1361,33 @@ test_expect_success '"status.short=false" weaker than "-s"' '
        test_cmp expected_short actual
 '
 
+test_expect_success '"status.branch=true" same as "-b"' '
+       git status -sb >expected_branch &&
+       git -c status.branch=true status -s >actual &&
+       test_cmp expected_branch actual
+'
+
+test_expect_success '"status.branch=true" different from "--no-branch"' '
+       git status -s --no-branch  >expected_nobranch &&
+       git -c status.branch=true status -s >actual &&
+       test_must_fail test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=true" weaker than "--no-branch"' '
+       git -c status.branch=true status -s --no-branch >actual &&
+       test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=false" same as "--no-branch"' '
+       git -c status.branch=false status -s >actual &&
+       test_cmp expected_nobranch actual
+'
+
+test_expect_success '"status.branch=false" weaker than "-b"' '
+       git -c status.branch=false status -sb >actual &&
+       test_cmp expected_branch actual
+'
+
 test_expect_success 'Restore default test environment' '
        git config --unset status.showUntrackedFiles
 '