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>
Jorge Juan Garcia Garcia committed
Jun 11, 2013 at 15:34 UTC
ec85d0700faac679ec27eeacad2bcaa6d9bc8322
3 files changed
+35
Documentation/config.txt
+4
@@ -2070,6 +2070,10 @@ status.short::
2070
Set to true to enable --short by default in linkgit:git-status[1].
2071
The option --no-short takes precedence over this variable.
2072
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
+
2077
status.showUntrackedFiles::
2078
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
2079
files which are not currently tracked by Git. Directories which
builtin/commit.c
+4
@@ -1117,6 +1117,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
1117
status_format = STATUS_FORMAT_NONE;
1118
return 0;
1119
}
1120
+ if (!strcmp(k, "status.branch")) {
1121
+ s->show_branch = git_config_bool(k, v);
1122
+ return 0;
1123
+ }
1124
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
1125
s->use_color = git_config_colorbool(k, v);
1126
return 0;
t/t7508-status.sh
+27
@@ -1361,6 +1361,33 @@ test_expect_success '"status.short=false" weaker than "-s"' '
1361
test_cmp expected_short actual
1362
'
1363
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
+
1391
test_expect_success 'Restore default test environment' '
1392
git config --unset status.showUntrackedFiles
1393
'