Skip to content

Commit ec85d07

Browse files
Jorge Juan Garcia Garciagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Mathieu Lienard--Mayor <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4fb5166 commit ec85d07

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

Documentation/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,10 @@ status.short::
20702070
Set to true to enable --short by default in linkgit:git-status[1].
20712071
The option --no-short takes precedence over this variable.
20722072

2073+
status.branch::
2074+
Set to true to enable --branch by default in linkgit:git-status[1].
2075+
The option --no-branch takes precedence over this variable.
2076+
20732077
status.showUntrackedFiles::
20742078
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
20752079
files which are not currently tracked by Git. Directories which

builtin/commit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
11171117
status_format = STATUS_FORMAT_NONE;
11181118
return 0;
11191119
}
1120+
if (!strcmp(k, "status.branch")) {
1121+
s->show_branch = git_config_bool(k, v);
1122+
return 0;
1123+
}
11201124
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
11211125
s->use_color = git_config_colorbool(k, v);
11221126
return 0;

t/t7508-status.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,33 @@ test_expect_success '"status.short=false" weaker than "-s"' '
13611361
test_cmp expected_short actual
13621362
'
13631363

1364+
test_expect_success '"status.branch=true" same as "-b"' '
1365+
git status -sb >expected_branch &&
1366+
git -c status.branch=true status -s >actual &&
1367+
test_cmp expected_branch actual
1368+
'
1369+
1370+
test_expect_success '"status.branch=true" different from "--no-branch"' '
1371+
git status -s --no-branch >expected_nobranch &&
1372+
git -c status.branch=true status -s >actual &&
1373+
test_must_fail test_cmp expected_nobranch actual
1374+
'
1375+
1376+
test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1377+
git -c status.branch=true status -s --no-branch >actual &&
1378+
test_cmp expected_nobranch actual
1379+
'
1380+
1381+
test_expect_success '"status.branch=false" same as "--no-branch"' '
1382+
git -c status.branch=false status -s >actual &&
1383+
test_cmp expected_nobranch actual
1384+
'
1385+
1386+
test_expect_success '"status.branch=false" weaker than "-b"' '
1387+
git -c status.branch=false status -sb >actual &&
1388+
test_cmp expected_branch actual
1389+
'
1390+
13641391
test_expect_success 'Restore default test environment' '
13651392
git config --unset status.showUntrackedFiles
13661393
'

0 commit comments

Comments
 (0)