Skip to content

Commit

Permalink
status: introduce status.branch to enable --branch by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jorge Juan Garcia Garcia authored and Junio C Hamano committed Jun 24, 2013
1 parent 4fb5166 commit ec85d07
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand Down

0 comments on commit ec85d07

Please sign in to comment.