status: introduce status.branch to enable --branch by default

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>
This commit is contained in:
Jorge Juan Garcia Garcia 2013-06-11 15:34:05 +02:00 коммит произвёл Junio C Hamano
Родитель 4fb5166ab5
Коммит ec85d0700f
3 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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
'