diff mbox series

[1/4] reset: do not make '--quiet' disable index refresh

Message ID f89e9b4ae24718116d0275333f4ece1d4024ab6b.1647894889.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series reset: make --no-refresh the only way to skip index refresh | expand

Commit Message

Victoria Dye March 21, 2022, 8:34 p.m. UTC
From: Victoria Dye <vdye@github.com>

Update '--quiet' to no longer implicitly skip refreshing the index in a
mixed reset. Users now have the ability to explicitly disable refreshing the
index with the '--no-refresh' option, so they no longer need to use
'--quiet' to do so. Moreover, we explicitly remove the refresh-skipping
behavior from '--quiet' because it is completely unrelated to the stated
purpose of the option: "Be quiet, only report errors."

Signed-off-by: Victoria Dye <vdye@github.com>
---
 Documentation/git-reset.txt |  5 +----
 builtin/reset.c             |  7 -------
 t/t7102-reset.sh            | 32 +++++---------------------------
 3 files changed, 6 insertions(+), 38 deletions(-)

Comments

Phillip Wood March 23, 2022, 3:59 p.m. UTC | #1
Hi Victoria

On 21/03/2022 20:34, Victoria Dye via GitGitGadget wrote:
> From: Victoria Dye <vdye@github.com>
> 
> Update '--quiet' to no longer implicitly skip refreshing the index in a
> mixed reset. Users now have the ability to explicitly disable refreshing the
> index with the '--no-refresh' option, so they no longer need to use
> '--quiet' to do so. Moreover, we explicitly remove the refresh-skipping
> behavior from '--quiet' because it is completely unrelated to the stated
> purpose of the option: "Be quiet, only report errors."
> 
> Signed-off-by: Victoria Dye <vdye@github.com>
> ---
>   Documentation/git-reset.txt |  5 +----
>   builtin/reset.c             |  7 -------
>   t/t7102-reset.sh            | 32 +++++---------------------------
>   3 files changed, 6 insertions(+), 38 deletions(-)
> 
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 89ddc85c2e4..bc1646c3016 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -114,10 +114,7 @@ OPTIONS
>   --no-refresh::
>   	Proactively refresh the index after a mixed reset. If unspecified, the
>   	behavior falls back on the `reset.refresh` config option. If neither
> -	`--[no-]refresh` nor `reset.refresh` are set, the default behavior is
> -	decided by the `--[no-]quiet` option and/or `reset.quiet` config.
> -	If `--quiet` is specified or `reset.quiet` is set with no command-line
> -	"quiet" setting, refresh is disabled. Otherwise, refresh is enabled.
> +	`--[no-]refresh` nor `reset.refresh` are set, refresh is enabled.
>   
>   --pathspec-from-file=<file>::
>   	Pathspec is passed in `<file>` instead of commandline args. If
> diff --git a/builtin/reset.c b/builtin/reset.c
> index c8a356ec5b0..7c3828f6fc5 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -430,13 +430,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>   						PARSE_OPT_KEEP_DASHDASH);
>   	parse_args(&pathspec, argv, prefix, patch_mode, &rev);
>   
> -	/*
> -	 * If refresh is completely unspecified (either by config or by command
> -	 * line option), decide based on 'quiet'.
> -	 */
> -	if (refresh < 0)
> -		refresh = !quiet;

Does this mean we can stop initializing refresh to -1?

Best Wishes

Phillip
Victoria Dye March 23, 2022, 4:52 p.m. UTC | #2
Phillip Wood wrote:
> Hi Victoria
> 
> On 21/03/2022 20:34, Victoria Dye via GitGitGadget wrote:
>> From: Victoria Dye <vdye@github.com>
>>
>> Update '--quiet' to no longer implicitly skip refreshing the index in a
>> mixed reset. Users now have the ability to explicitly disable refreshing the
>> index with the '--no-refresh' option, so they no longer need to use
>> '--quiet' to do so. Moreover, we explicitly remove the refresh-skipping
>> behavior from '--quiet' because it is completely unrelated to the stated
>> purpose of the option: "Be quiet, only report errors."
>>
>> Signed-off-by: Victoria Dye <vdye@github.com>
>> ---
>>   Documentation/git-reset.txt |  5 +----
>>   builtin/reset.c             |  7 -------
>>   t/t7102-reset.sh            | 32 +++++---------------------------
>>   3 files changed, 6 insertions(+), 38 deletions(-)
>>
>> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
>> index 89ddc85c2e4..bc1646c3016 100644
>> --- a/Documentation/git-reset.txt
>> +++ b/Documentation/git-reset.txt
>> @@ -114,10 +114,7 @@ OPTIONS
>>   --no-refresh::
>>       Proactively refresh the index after a mixed reset. If unspecified, the
>>       behavior falls back on the `reset.refresh` config option. If neither
>> -    `--[no-]refresh` nor `reset.refresh` are set, the default behavior is
>> -    decided by the `--[no-]quiet` option and/or `reset.quiet` config.
>> -    If `--quiet` is specified or `reset.quiet` is set with no command-line
>> -    "quiet" setting, refresh is disabled. Otherwise, refresh is enabled.
>> +    `--[no-]refresh` nor `reset.refresh` are set, refresh is enabled.
>>     --pathspec-from-file=<file>::
>>       Pathspec is passed in `<file>` instead of commandline args. If
>> diff --git a/builtin/reset.c b/builtin/reset.c
>> index c8a356ec5b0..7c3828f6fc5 100644
>> --- a/builtin/reset.c
>> +++ b/builtin/reset.c
>> @@ -430,13 +430,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>>                           PARSE_OPT_KEEP_DASHDASH);
>>       parse_args(&pathspec, argv, prefix, patch_mode, &rev);
>>   -    /*
>> -     * If refresh is completely unspecified (either by config or by command
>> -     * line option), decide based on 'quiet'.
>> -     */
>> -    if (refresh < 0)
>> -        refresh = !quiet;
> 
> Does this mean we can stop initializing refresh to -1?
> 
> Best Wishes
> 
> Phillip

Yes, thanks for catching that! It should be initialized to 1 in this patch
(rather than later in patch 4).
diff mbox series

Patch

diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 89ddc85c2e4..bc1646c3016 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -114,10 +114,7 @@  OPTIONS
 --no-refresh::
 	Proactively refresh the index after a mixed reset. If unspecified, the
 	behavior falls back on the `reset.refresh` config option. If neither
-	`--[no-]refresh` nor `reset.refresh` are set, the default behavior is
-	decided by the `--[no-]quiet` option and/or `reset.quiet` config.
-	If `--quiet` is specified or `reset.quiet` is set with no command-line
-	"quiet" setting, refresh is disabled. Otherwise, refresh is enabled.
+	`--[no-]refresh` nor `reset.refresh` are set, refresh is enabled.
 
 --pathspec-from-file=<file>::
 	Pathspec is passed in `<file>` instead of commandline args. If
diff --git a/builtin/reset.c b/builtin/reset.c
index c8a356ec5b0..7c3828f6fc5 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -430,13 +430,6 @@  int cmd_reset(int argc, const char **argv, const char *prefix)
 						PARSE_OPT_KEEP_DASHDASH);
 	parse_args(&pathspec, argv, prefix, patch_mode, &rev);
 
-	/*
-	 * If refresh is completely unspecified (either by config or by command
-	 * line option), decide based on 'quiet'.
-	 */
-	if (refresh < 0)
-		refresh = !quiet;
-
 	if (pathspec_from_file) {
 		if (patch_mode)
 			die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--patch");
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 1dc3911a060..8b62bb39b3d 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -485,25 +485,12 @@  test_reset_refreshes_index () {
 }
 
 test_expect_success '--mixed refreshes the index' '
-	# Verify default behavior (with no config settings or command line
-	# options)
-	test_reset_refreshes_index
-'
-test_expect_success '--mixed --[no-]quiet sets default refresh behavior' '
-	# Verify that --[no-]quiet and `reset.quiet` (without --[no-]refresh)
-	# determine refresh behavior
-
-	# Config setting
-	! test_reset_refreshes_index "-c reset.quiet=true" &&
-	test_reset_refreshes_index "-c reset.quiet=false" &&
-
-	# Command line option
-	! test_reset_refreshes_index "" --quiet &&
-	test_reset_refreshes_index "" --no-quiet &&
+	# Verify default behavior (without --[no-]refresh or reset.refresh)
+	test_reset_refreshes_index &&
 
-	# Command line option overrides config setting
-	! test_reset_refreshes_index "-c reset.quiet=false" --quiet &&
-	test_reset_refreshes_index "-c reset.refresh=true" --no-quiet
+	# With --quiet & reset.quiet
+	test_reset_refreshes_index "-c reset.quiet=true" &&
+	test_reset_refreshes_index "" --quiet
 '
 
 test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
@@ -522,15 +509,6 @@  test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
 	! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh
 '
 
-test_expect_success '--mixed --refresh overrides --quiet refresh behavior' '
-	# Verify that *both* --refresh and `reset.refresh` override the
-	# default non-refresh behavior of --quiet
-	test_reset_refreshes_index "" "--quiet --refresh" &&
-	test_reset_refreshes_index "-c reset.quiet=true" --refresh &&
-	test_reset_refreshes_index "-c reset.refresh=true" --quiet &&
-	test_reset_refreshes_index "-c reset.refresh=true -c reset.quiet=true"
-'
-
 test_expect_success '--mixed preserves skip-worktree' '
 	echo 123 >>file2 &&
 	git add file2 &&