Skip to content

Commit 4fb5166

Browse files
Jorge Juan Garcia Garciagitster
authored andcommitted
status: introduce status.short to enable --short by default
Some people always run 'git status -s'. The configuration variable status.short 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 edca415 commit 4fb5166

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

Documentation/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,10 @@ status.relativePaths::
20662066
relative to the repository root (this was the default for Git
20672067
prior to v1.5.4).
20682068

2069+
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+
20692073
status.showUntrackedFiles::
20702074
By default, linkgit:git-status[1] and linkgit:git-commit[1] show
20712075
files which are not currently tracked by Git. Directories which

builtin/commit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,13 @@ static int git_status_config(const char *k, const char *v, void *cb)
11101110
s->submodule_summary = -1;
11111111
return 0;
11121112
}
1113+
if (!strcmp(k, "status.short")) {
1114+
if (git_config_bool(k, v))
1115+
status_format = STATUS_FORMAT_SHORT;
1116+
else
1117+
status_format = STATUS_FORMAT_NONE;
1118+
return 0;
1119+
}
11131120
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
11141121
s->use_color = git_config_colorbool(k, v);
11151122
return 0;

t/t7508-status.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,4 +1335,34 @@ 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 'Restore default test environment' '
1365+
git config --unset status.showUntrackedFiles
1366+
'
1367+
13381368
test_done

0 commit comments

Comments
 (0)