Skip to content

Commit 1a22bd3

Browse files
committed
Merge branch 'jg/status-config'
"git status" learned status.branch and status.short configuration variables to use --branch and --short options by default (override with --no-branch and --no-short options from the command line). * jg/status-config: status: introduce status.branch to enable --branch by default status: introduce status.short to enable --short by default
2 parents 3e7a5b4 + 0e254bb commit 1a22bd3

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

Documentation/config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,14 @@ status.relativePaths::
20752075
relative to the repository root (this was the default for Git
20762076
prior to v1.5.4).
20772077

2078+
status.short::
2079+
Set to true to enable --short by default in linkgit:git-status[1].
2080+
The option --no-short takes precedence over this variable.
2081+
2082+
status.branch::
2083+
Set to true to enable --branch by default in linkgit:git-status[1].
2084+
The option --no-branch takes precedence over this variable.
2085+
20782086
status.showUntrackedFiles::
20792087
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
20802088
files which are not currently tracked by Git. Directories which

builtin/commit.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,17 @@ static int git_status_config(const char *k, const char *v, void *cb)
11121112
s->submodule_summary = -1;
11131113
return 0;
11141114
}
1115+
if (!strcmp(k, "status.short")) {
1116+
if (git_config_bool(k, v))
1117+
status_format = STATUS_FORMAT_SHORT;
1118+
else
1119+
status_format = STATUS_FORMAT_NONE;
1120+
return 0;
1121+
}
1122+
if (!strcmp(k, "status.branch")) {
1123+
s->show_branch = git_config_bool(k, v);
1124+
return 0;
1125+
}
11151126
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
11161127
s->use_color = git_config_colorbool(k, v);
11171128
return 0;

t/t7508-status.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,4 +1335,61 @@ test_expect_failure '.git/config ignore=all suppresses submodule summary' '
13351335
git config -f .gitmodules --remove-section submodule.subname
13361336
'
13371337

1338+
test_expect_success 'setup of test environment' '
1339+
git config status.showUntrackedFiles no &&
1340+
git status -s >expected_short &&
1341+
git status --no-short >expected_noshort
1342+
'
1343+
1344+
test_expect_success '"status.short=true" same as "-s"' '
1345+
git -c status.short=true status >actual &&
1346+
test_cmp expected_short actual
1347+
'
1348+
1349+
test_expect_success '"status.short=true" weaker than "--no-short"' '
1350+
git -c status.short=true status --no-short >actual &&
1351+
test_cmp expected_noshort actual
1352+
'
1353+
1354+
test_expect_success '"status.short=false" same as "--no-short"' '
1355+
git -c status.short=false status >actual &&
1356+
test_cmp expected_noshort actual
1357+
'
1358+
1359+
test_expect_success '"status.short=false" weaker than "-s"' '
1360+
git -c status.short=false status -s >actual &&
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+
'
1394+
13381395
test_done

0 commit comments

Comments
 (0)