status: allow --untracked=false and friends
It is natural to expect that the "--untracked" option and the status.showuntrackedFiles configuration variable to take a Boolean value ("do you want me to show untracked files?"), but the current code takes nothing but "no" as "no, please do not show any". Allow the usual Boolean values to be given, and treat 'true' as "normal", and 'false' as "no". Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
63acdc4827
commit
f66e1a071b
|
@ -57,6 +57,8 @@ status.showUntrackedFiles::
|
||||||
--
|
--
|
||||||
+
|
+
|
||||||
If this variable is not specified, it defaults to 'normal'.
|
If this variable is not specified, it defaults to 'normal'.
|
||||||
|
All usual spellings for Boolean value `true` are taken as `normal`
|
||||||
|
and `false` as `no`.
|
||||||
This variable can be overridden with the -u|--untracked-files option
|
This variable can be overridden with the -u|--untracked-files option
|
||||||
of linkgit:git-status[1] and linkgit:git-commit[1].
|
of linkgit:git-status[1] and linkgit:git-commit[1].
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,8 @@ The possible options are:
|
||||||
- 'normal' - Shows untracked files and directories
|
- 'normal' - Shows untracked files and directories
|
||||||
- 'all' - Also shows individual files in untracked directories.
|
- 'all' - Also shows individual files in untracked directories.
|
||||||
|
|
||||||
|
All usual spellings for Boolean value `true` are taken as `normal`
|
||||||
|
and `false` as `no`.
|
||||||
The default can be changed using the status.showUntrackedFiles
|
The default can be changed using the status.showUntrackedFiles
|
||||||
configuration variable documented in linkgit:git-config[1].
|
configuration variable documented in linkgit:git-config[1].
|
||||||
--
|
--
|
||||||
|
|
|
@ -79,6 +79,8 @@ Consider enabling untracked cache and split index if supported (see
|
||||||
`git update-index --untracked-cache` and `git update-index
|
`git update-index --untracked-cache` and `git update-index
|
||||||
--split-index`), Otherwise you can use `no` to have `git status`
|
--split-index`), Otherwise you can use `no` to have `git status`
|
||||||
return more quickly without showing untracked files.
|
return more quickly without showing untracked files.
|
||||||
|
All usual spellings for Boolean value `true` are taken as `normal`
|
||||||
|
and `false` as `no`.
|
||||||
|
|
||||||
The default can be changed using the status.showUntrackedFiles
|
The default can be changed using the status.showUntrackedFiles
|
||||||
configuration variable documented in linkgit:git-config[1].
|
configuration variable documented in linkgit:git-config[1].
|
||||||
|
|
|
@ -1163,6 +1163,17 @@ static enum untracked_status_type parse_untracked_setting_name(const char *u)
|
||||||
* Please update $__git_untracked_file_modes in
|
* Please update $__git_untracked_file_modes in
|
||||||
* git-completion.bash when you add new options
|
* git-completion.bash when you add new options
|
||||||
*/
|
*/
|
||||||
|
switch (git_parse_maybe_bool(u)) {
|
||||||
|
case 0:
|
||||||
|
u = "no";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
u = "normal";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(u, "no"))
|
if (!strcmp(u, "no"))
|
||||||
return SHOW_NO_UNTRACKED_FILES;
|
return SHOW_NO_UNTRACKED_FILES;
|
||||||
else if (!strcmp(u, "normal"))
|
else if (!strcmp(u, "normal"))
|
||||||
|
@ -1469,8 +1480,6 @@ static int git_status_config(const char *k, const char *v,
|
||||||
if (!strcmp(k, "status.showuntrackedfiles")) {
|
if (!strcmp(k, "status.showuntrackedfiles")) {
|
||||||
enum untracked_status_type u;
|
enum untracked_status_type u;
|
||||||
|
|
||||||
if (!v)
|
|
||||||
return config_error_nonbool(k);
|
|
||||||
u = parse_untracked_setting_name(v);
|
u = parse_untracked_setting_name(v);
|
||||||
if (u == SHOW_UNTRACKED_FILES_ERROR)
|
if (u == SHOW_UNTRACKED_FILES_ERROR)
|
||||||
return error(_("Invalid untracked files mode '%s'"), v);
|
return error(_("Invalid untracked files mode '%s'"), v);
|
||||||
|
|
|
@ -419,14 +419,19 @@ Changes not staged for commit:
|
||||||
Untracked files not listed (use -u option to show untracked files)
|
Untracked files not listed (use -u option to show untracked files)
|
||||||
EOF
|
EOF
|
||||||
git status -uno >output &&
|
git status -uno >output &&
|
||||||
|
test_cmp expect output &&
|
||||||
|
git status -ufalse >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'status (status.showUntrackedFiles no)' '
|
for no in no false 0
|
||||||
test_config status.showuntrackedfiles no &&
|
do
|
||||||
git status >output &&
|
test_expect_success "status (status.showUntrackedFiles $no)" '
|
||||||
test_cmp expect output
|
test_config status.showuntrackedfiles "$no" &&
|
||||||
'
|
git status >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
done
|
||||||
|
|
||||||
test_expect_success 'status -uno (advice.statusHints false)' '
|
test_expect_success 'status -uno (advice.statusHints false)' '
|
||||||
cat >expect <<EOF &&
|
cat >expect <<EOF &&
|
||||||
|
@ -488,14 +493,21 @@ Untracked files:
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
git status -unormal >output &&
|
git status -unormal >output &&
|
||||||
|
test_cmp expect output &&
|
||||||
|
git status -utrue >output &&
|
||||||
|
test_cmp expect output &&
|
||||||
|
git status -uyes >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'status (status.showUntrackedFiles normal)' '
|
for normal in normal true 1
|
||||||
test_config status.showuntrackedfiles normal &&
|
do
|
||||||
git status >output &&
|
test_expect_success "status (status.showUntrackedFiles $normal)" '
|
||||||
test_cmp expect output
|
test_config status.showuntrackedfiles $normal &&
|
||||||
'
|
git status >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
done
|
||||||
|
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
M dir1/modified
|
M dir1/modified
|
||||||
|
|
Loading…
Reference in New Issue