diff options
-rw-r--r-- | Documentation/config.txt | 4 | ||||
-rw-r--r-- | builtin/commit.c | 4 | ||||
-rwxr-xr-x | t/t7508-status.sh | 27 |
3 files changed, 35 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt index 1983bf7427..ecdcd6dd99 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -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 diff --git a/builtin/commit.c b/builtin/commit.c index b2f41dea20..d6c8e204ee 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -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; diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 33cadd08c7..498332ce0a 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -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 ' |