reset: make --no-refresh the only way to skip index refresh
cover reset: make --no-refresh the only way to skip index refresh
Maintainer's note: this is based on vd/stash-silence-reset
----------------------------------------------------------------------------
This is a follow-up to the changes in vd/stash-silence-reset [1], in which index refreshing behavior was decoupled from log silencing in the '--quiet' option to 'git reset --mixed' by introducing a '--[no-]refresh' option and 'reset.refresh' config setting.
After some discussion [2] on the mailing list, both the backward-compatibility and use of global options in that series came into question:
* '--quiet' still skipped refresh if neither '--[no-]refresh' nor 'reset.refresh' were specified, meaning that users could still be left with an incorrect index state after reset.
* Having 'reset.quiet' and/or 'reset.refresh' potentially disable index refresh by default meant that developers would need to defensively add '--refresh' to all internal uses of 'git reset --mixed'. Without that option, different config setups could cause variability in index correctness from user to user.
In response, this series deprecates all instances of skipping index refresh in 'git reset --mixed' except for '--no-refresh' itself:
* Patch [1/4] removes the "fallback" behavior of 'reset.quiet' and '--quiet' implying '--no-refresh' if neither '--[no-]refresh' nor 'config.refresh' were specified. In other words, '--quiet' no longer does anything other than log silencing.
* Patch [2/4] deprecates 'reset.quiet', since its main use was to disable index refresh until it was deprecated in [1/4].
* Patch [3/4] deprecates 'reset.refresh' to avoid users accidentally ending up with an incorrect index state after all resets as a result of a global setting's passive effects.
* Patch [4/4] removes the '--refresh' option, leaving only '--no-refresh'. Because nothing but '--no-refresh' can skip the 'reset' index refresh anymore, '--refresh' would never be needed.
[1]
https://lore.kernel.org/git/[email protected]/
[2]
https://lore.kernel.org/git/[email protected]/
Thanks! -Victoria
Victoria Dye (4):
reset: do not make '--quiet' disable index refresh
reset: deprecate 'reset.quiet' config option
reset: deprecate 'reset.refresh' config option
reset: deprecate '--refresh', leaving only '--no-refresh'
Documentation/config.txt | 2 -- Documentation/config/reset.txt | 2 -- Documentation/git-reset.txt | 13 ++------- builtin/reset.c | 18 +++---------- builtin/stash.c | 4 +-- contrib/scalar/scalar.c | 1 - t/t7102-reset.sh | 48 +++++----------------------------- 7 files changed, 15 insertions(+), 73 deletions(-) delete mode 100644 Documentation/config/reset.txt
base-commit: 4b8b0f6fa2778c1f9c373620e3f07787543914c6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1184%2Fvdye%2Freset%2Fclean-up-refresh-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1184/vdye/reset/clean-up-refresh-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1184
Signature · 1 line
gitgitgadget
PATCH 2/4 reset: deprecate 'reset.quiet' config option
From: Victoria Dye <[email protected]>
Remove the 'reset.quiet' config option, remove '--no-quiet' documentation in 'Documentation/git-reset.txt'. In 4c3abd0551 (reset: add new reset.quiet config setting, 2018-10-23), 'reset.quiet' was introduced as a way to globally change the default behavior of 'git reset --mixed' to skip index refresh.
However, now that '--quiet' does not affect index refresh, 'reset.quiet' would only serve to globally silence logging. This was not the original intention of the config setting, and there's no precedent for such a setting in other commands with a '--quiet' option, so it appears to be obsolete.
In addition to the options & its documentation, remove 'reset.quiet' from the recommended config for 'scalar'.
--- Documentation/config.txt | 2 -- Documentation/config/reset.txt | 2 -- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 1 - contrib/scalar/scalar.c | 1 - t/t7102-reset.sh | 3 +-- 6 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 Documentation/config/reset.txt
Documentation/config.txt +0 -2
@@ -495,8 +495,6 @@ include::config/repack.txt[] include::config/rerere.txt[] -include::config/reset.txt[] - include::config/sendemail.txt[] include::config/sequencer.txt[]
Documentation/config/reset.txt deleted +0 -2
@@ -1,2 +0,0 @@ -reset.quiet:: - When set to true, 'git reset' will default to the '--quiet' option.
Documentation/git-reset.txt +1 -4
@@ -105,10 +105,7 @@ OPTIONS -q:: --quiet:: ---no-quiet:: - Be quiet, only report errors. The default behavior is set by the - `reset.quiet` config option. `--quiet` and `--no-quiet` will - override the default behavior. + Be quiet, only report errors. --refresh:: --no-refresh::
builtin/reset.c +0 -1
@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.quiet" , &quiet);git_config_get_bool ("reset.refresh" , &refresh); argc = parse_options(argc, argv, prefix, options, git_reset_usage,
contrib/scalar/scalar.c +0 -1
@@ -152,7 +152,6 @@ static int set_recommended_config(int reconfigure) { "pack.useBitmaps", "false", 1 }, { "pack.useSparse", "true", 1 }, { "receive.autoGC", "false", 1 }, - { "reset.quiet", "true", 1 }, { "feature.manyFiles", "false", 1 }, { "feature.experimental", "false", 1 }, { "fetch.unpackLimit", "1", 1 },
t/t7102-reset.sh +1 -2
@@ -488,8 +488,7 @@ test_expect_success '--mixed refreshes the index' ' # Verify default behavior (without --[no-]refresh or reset.refresh) test_reset_refreshes_index && - # With --quiet & reset.quiet - test_reset_refreshes_index "-c reset.quiet=true" && + # With --quiet test_reset_refreshes_index "" --quiet '
Signature · 1 line
gitgitgadget
PATCH 1/4 reset: do not make '--quiet' disable index refresh
In reply to Victoria Dye via GitGitGadgetFrom: Victoria Dye <[email protected]>
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."
--- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 7 ------- t/t7102-reset.sh | 32 +++++--------------------------- 3 files changed, 6 insertions(+), 38 deletions(-)
Documentation/git-reset.txt +1 -4
@@ -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
builtin/reset.c +0 -7
@@ -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" );
t/t7102-reset.sh +5 -27
@@ -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 &&
Signature · 1 line
gitgitgadget
PATCH 3/4 reset: deprecate 'reset.refresh' config option
In reply to Victoria Dye via GitGitGadgetFrom: Victoria Dye <[email protected]>
Remove the 'reset.refresh' option, requiring that users explicitly specify '--no-refresh' if they want to skip refreshing the index.
The 'reset.refresh' option was introduced in 101cee42dd (reset: introduce --[no-]refresh option to --mixed, 2022-03-11) as a replacement for the refresh-skipping behavior originally controlled by 'reset.quiet'.
Although 'reset.refresh=false' functionally served the same purpose as 'reset.quiet=true', it exposed [1] the fact that the existence of a global "skip refresh" option could potentially cause problems for users. Allowing a global config option to avoid refreshing the index forces scripts using 'git reset --mixed' to defensively use '--refresh' if index refresh is expected; if that option is missing, behavior of a script could vary from user-to-user without explanation.
Furthermore, globally disabling index refresh in 'reset --mixed' was initially devised as a passive performance improvement; since the introduction of the option, other changes have been made to Git (e.g., the sparse index) with a greater potential performance impact without sacrificing index correctness. Therefore, we can more aggressively err on the side of correctness and limit the cases of skipping index refresh to only when a user specifies the '--no-refresh' option.
[1] https://lore.kernel.org/git/[email protected]/
--- Documentation/git-reset.txt | 4 +--- builtin/reset.c | 4 +--- t/t7102-reset.sh | 14 ++------------ 3 files changed, 4 insertions(+), 18 deletions(-)
Documentation/git-reset.txt +1 -3
@@ -109,9 +109,7 @@ OPTIONS --refresh:: --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, refresh is enabled. + Proactively refresh the index after a mixed reset. Enabled by default. --pathspec-from-file=<file>:: Pathspec is passed in `<file>` instead of commandline args. If
builtin/reset.c +1 -3
@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.refresh" , &refresh); argc =parse_options (argc, argv, prefix, options, git_reset_usage,PARSE_OPT_KEEP_DASHDASH );
@@ -529,8 +528,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) t_delta_in_ms = (getnanotime () - t_begin) /1000000 ;if (!quiet &&advice_enabled (ADVICE_RESET_NO_REFRESH_WARNING ) && t_delta_in_ms >REFRESH_INDEX_DELAY_WARNING_IN_MS ) {advise (_ ("It took %.2f seconds to refresh the index after reset. You can use\n" -"'--no-refresh' to avoid this. Set the config setting reset.refresh to false\n" -"to make this the default." ), t_delta_in_ms /1000.0 ); +"'--no-refresh' to avoid this." ), t_delta_in_ms /1000.0 ); } } }else {
t/t7102-reset.sh +2 -12
@@ -493,19 +493,9 @@ test_expect_success '--mixed refreshes the index' ' ' test_expect_success '--mixed --[no-]refresh sets refresh behavior' ' - # Verify that --[no-]refresh and `reset.refresh` control index refresh - - # Config setting - test_reset_refreshes_index "-c reset.refresh=true" && - ! test_reset_refreshes_index "-c reset.refresh=false" && - - # Command line option + # Verify that --[no-]refresh controls index refresh test_reset_refreshes_index "" --refresh && - ! test_reset_refreshes_index "" --no-refresh && - - # Command line option overrides config setting - test_reset_refreshes_index "-c reset.refresh=false" --refresh && - ! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh + ! test_reset_refreshes_index "" --no-refresh ' test_expect_success '--mixed preserves skip-worktree' '
Signature · 1 line
gitgitgadget
PATCH 4/4 reset: deprecate '--refresh', leaving only '--no-refresh'
In reply to Victoria Dye via GitGitGadgetFrom: Victoria Dye <[email protected]>
The explicit '--refresh' option was needed in the past when '--quiet', 'reset.quiet', and/or 'reset.refresh' disabled the index refresh in 'reset --mixed'. Those options have since either been deprecated or made to always refresh the index by default, leaving only '--[no-]refresh' determining whether the index is refreshed or not.
Because there is nothing other than '--no-refresh' to disable index refresh, we do not need a '--refresh' option to counteract some other refresh disabling.
To ensure users don't use what is effectively a no-op, remove '--refresh' from the set of 'reset' options, as well as its usage in 'git stash'.
--- Documentation/git-reset.txt | 3 +-- builtin/reset.c | 6 +++--- builtin/stash.c | 4 ++-- t/t7102-reset.sh | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-)
Documentation/git-reset.txt +1 -2
@@ -107,9 +107,8 @@ OPTIONS --quiet:: Be quiet, only report errors. ---refresh:: --no-refresh:: - Proactively refresh the index after a mixed reset. Enabled by default. + Disable refreshing the index after a mixed reset. --pathspec-from-file=<file>:: Pathspec is passed in `<file>` instead of commandline args. If
builtin/reset.c +3 -3
@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =-1 ; +int refresh =1 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;
@@ -400,8 +400,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)int intent_to_add =0 ;const struct option options[] = {OPT__QUIET (&quiet,N_ ("be quiet, only report errors" )), -OPT_BOOL (0 ,"refresh" , &refresh, -N_ ("skip refreshing the index after reset" )), +OPT_SET_INT (0 ,"no-refresh" , &refresh, +N_ ("skip refreshing the index after reset" ),0 ),OPT_SET_INT (0 ,"mixed" , &reset_type,N_ ("reset HEAD and index" ),MIXED ),OPT_SET_INT (0 ,"soft" , &reset_type,N_ ("reset only HEAD" ),SOFT ),
builtin/stash.c +2 -2
@@ -310,7 +310,7 @@ static int reset_head(void)* API for resetting. */ cp.git_cmd =1 ; -strvec_pushl (&cp.args,"reset" ,"--quiet" ,"--refresh" ,NULL ); +strvec_pushl (&cp.args,"reset" ,"--quiet" ,NULL );return run_command (&cp); }
@@ -1633,7 +1633,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int qstruct child_process cp =CHILD_PROCESS_INIT ; cp.git_cmd =1 ; -strvec_pushl (&cp.args,"reset" ,"-q" ,"--refresh" ,"--" , +strvec_pushl (&cp.args,"reset" ,"-q" ,"--" ,NULL );add_pathspecs (&cp.args, ps);if (run_command (&cp)) {
t/t7102-reset.sh +2 -3
@@ -492,9 +492,8 @@ test_expect_success '--mixed refreshes the index' ' test_reset_refreshes_index "" --quiet ' -test_expect_success '--mixed --[no-]refresh sets refresh behavior' ' - # Verify that --[no-]refresh controls index refresh - test_reset_refreshes_index "" --refresh && +test_expect_success '--mixed --no-refresh sets refresh behavior' ' + # Verify that --no-refresh controls index refresh ! test_reset_refreshes_index "" --no-refresh '
Signature · 1 line
gitgitgadget
Re: [PATCH 1/4] reset: do not make '--quiet' disable index refresh
In reply to Victoria Dye via GitGitGadgetHi Victoria
Quoted 37 lines · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
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 <[email protected]>--- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 7 ------- t/t7102-reset.sh | 32 +++++--------------------------- 3 files changed, 6 insertions(+), 38 deletions(-)Documentation/git-reset.txt +1
-4@@ -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. Ifbuiltin/reset.c +0
-0
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 438
Quoted 9 lines
builtin/reset.c +0
-6@@ -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
Re: [PATCH 2/4] reset: deprecate 'reset.quiet' config option
In reply to Victoria Dye via GitGitGadgetHi Victoria
Quoted 1 line · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
Small nit-pick about the title, I think "deprecate" is a bit misleading as we're actually removing the config option.
Quoted 6 lines
Remove the 'reset.quiet' config option, remove '--no-quiet' documentation in '
Documentation/git-reset.txt'. In4c3abd0551(reset: add new reset.quiet config setting, 2018-10-23), 'reset.quiet' was introduced as a way to globally change the default behavior of 'git reset --mixed' to skip index refresh.
Quoted 7 lines
However, now that '--quiet' does not affect index refresh, 'reset.quiet' would only serve to globally silence logging. This was not the original intention of the config setting, and there's no precedent for such a setting in other commands with a '--quiet' option, so it appears to be obsolete.
In addition to the options & its documentation, remove 'reset.quiet' from the recommended config for 'scalar'.
Nice attention to detail
The code changes look good
Best Wishes
Phillip
Quoted 86 lines
Signed-off-by Victoria Dye <[email protected]>--- Documentation/config.txt | 2 -- Documentation/config/reset.txt | 2 -- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 1 - contrib/scalar/scalar.c | 1 - t/t7102-reset.sh | 3 +-- 6 files changed, 2 insertions(+), 12 deletions(-)delete mode 100644
Documentation/config/reset.txtDocumentation/config.txt +0
-2@@ -495,8 +495,6 @@ include::config/repack.txt[] include::config/rerere.txt[] -include::config/reset.txt[] - include::config/sendemail.txt[] include::config/sequencer.txt[]Documentation/config/reset.txt deleted +0
-2@@ -1,2 +0,0 @@ -reset.quiet:: - When set to true, 'git reset' will default to the '--quiet' option.Documentation/git-reset.txt +1
-4@@ -105,10 +105,7 @@ OPTIONS -q:: --quiet:: ---no-quiet:: - Be quiet, only report errors. The default behavior is set by the - `reset.quiet` config option. `--quiet` and `--no-quiet` will - override the default behavior. + Be quiet, only report errors. --refresh:: --no-refresh::builtin/reset.c +0
-1@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.quiet" , &quiet);git_config_get_bool ("reset.refresh" , &refresh); argc = parse_options(argc, argv, prefix, options, git_reset_usage,contrib/scalar/scalar.c +0
-1@@ -152,7 +152,6 @@ static int set_recommended_config(int reconfigure) { "pack.useBitmaps", "false", 1 }, { "pack.useSparse", "true", 1 }, { "receive.autoGC", "false", 1 }, - { "reset.quiet", "true", 1 }, { "feature.manyFiles", "false", 1 }, { "feature.experimental", "false", 1 }, { "fetch.unpackLimit", "1", 1 },t/t7102-reset.sh +1
-2@@ -488,8 +488,7 @@ test_expect_success '--mixed refreshes the index' ' # Verify default behavior (without --[no-]refresh or reset.refresh) test_reset_refreshes_index && - # With --quiet & reset.quiet - test_reset_refreshes_index "-c reset.quiet=true" && + # With --quiet test_reset_refreshes_index "" --quiet '
Re: [PATCH 3/4] reset: deprecate 'reset.refresh' config option
In reply to Victoria Dye via GitGitGadgetHi Victoria
Quoted 1 line · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
Same concern about the title as the last patch
Quoted 15 lines
Remove the 'reset.refresh' option, requiring that users explicitly specify '--no-refresh' if they want to skip refreshing the index.
The 'reset.refresh' option was introduced in
101cee42dd(reset: introduce --[no-]refresh option to --mixed, 2022-03-11) as a replacement for the refresh-skipping behavior originally controlled by 'reset.quiet'.Although 'reset.refresh=false' functionally served the same purpose as 'reset.quiet=true', it exposed [1] the fact that the existence of a global "skip refresh" option could potentially cause problems for users. Allowing a global config option to avoid refreshing the index forces scripts using 'git reset --mixed' to defensively use '--refresh' if index refresh is expected; if that option is missing, behavior of a script could vary from user-to-user without explanation.
Quoted 7 lines
Furthermore, globally disabling index refresh in 'reset --mixed' was initially devised as a passive performance improvement; since the introduction of the option, other changes have been made to Git (e.g., the sparse index) with a greater potential performance impact without sacrificing index correctness. Therefore, we can more aggressively err on the side of correctness and limit the cases of skipping index refresh to only when a user specifies the '--no-refresh' option.
Thanks for the well explained commit message
Quoted 14 lines
[1] https://lore.kernel.org/git/[email protected]/
Signed-off-by Victoria Dye <[email protected]>--- Documentation/git-reset.txt | 4 +--- builtin/reset.c | 4 +--- t/t7102-reset.sh | 14 ++------------ 3 files changed, 4 insertions(+), 18 deletions(-)Documentation/git-reset.txt +0
-0
Documentation/git-reset.txt OPTIONS · line 112
Quoted 7 lines
Documentation/git-reset.txt +1
-3@@ -109,9 +109,7 @@ OPTIONS --refresh:: --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, refresh is enabled. + Proactively refresh the index after a mixed reset. Enabled by default.
"Proactively" seems a but superfluous if I'm being picky. There was no entry in the config man page for reset.refresh so we don't need to do anything there. The code changes below look good
Best Wishes
Phillip
Quoted 50 lines
Documentation/git-reset.txt +0
-0--pathspec-from-file=<file>:: Pathspec is passed in `<file>` instead of commandline args. Ifbuiltin/reset.c +1
-3@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.refresh" , &refresh); argc =parse_options (argc, argv, prefix, options, git_reset_usage,PARSE_OPT_KEEP_DASHDASH );@@ -529,8 +528,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) t_delta_in_ms = (getnanotime () - t_begin) /1000000 ;if (!quiet &&advice_enabled (ADVICE_RESET_NO_REFRESH_WARNING ) && t_delta_in_ms >REFRESH_INDEX_DELAY_WARNING_IN_MS ) {advise (_ ("It took %.2f seconds to refresh the index after reset. You can use\n" -"'--no-refresh' to avoid this. Set the config setting reset.refresh to false\n" -"to make this the default." ), t_delta_in_ms /1000.0 ); +"'--no-refresh' to avoid this." ), t_delta_in_ms /1000.0 ); } } }else {t/t7102-reset.sh +2
-12@@ -493,19 +493,9 @@ test_expect_success '--mixed refreshes the index' ' ' test_expect_success '--mixed --[no-]refresh sets refresh behavior' ' - # Verify that --[no-]refresh and `reset.refresh` control index refresh - - # Config setting - test_reset_refreshes_index "-c reset.refresh=true" && - ! test_reset_refreshes_index "-c reset.refresh=false" && - - # Command line option + # Verify that --[no-]refresh controls index refresh test_reset_refreshes_index "" --refresh && - ! test_reset_refreshes_index "" --no-refresh && - - # Command line option overrides config setting - test_reset_refreshes_index "-c reset.refresh=false" --refresh && - ! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh + ! test_reset_refreshes_index "" --no-refresh ' test_expect_success '--mixed preserves skip-worktree' '
Re: [PATCH 4/4] reset: deprecate '--refresh', leaving only '--no-refresh'
In reply to Victoria Dye via GitGitGadgetHi Victoria
Quoted 11 lines · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
The explicit '--refresh' option was needed in the past when '--quiet', 'reset.quiet', and/or 'reset.refresh' disabled the index refresh in 'reset --mixed'. Those options have since either been deprecated or made to always refresh the index by default, leaving only '--[no-]refresh' determining whether the index is refreshed or not.
Because there is nothing other than '--no-refresh' to disable index refresh, we do not need a '--refresh' option to counteract some other refresh disabling.
'--refresh' could be used to countermand a previous '--no-refresh' (typically when using an alias that includes '--no-refresh'). Usually we have '--foo' even when it is enabled by default e.g. 'commit --verify'. I think the code below does actually support '--refresh' as parse_options() is smart enough to recognize option names beginning with '--no-' and creates an inverse option by removing the prefix rather than adding '--no-' as it normally does.
Quoted 40 lines
To ensure users don't use what is effectively a no-op, remove '--refresh' from the set of 'reset' options, as well as its usage in 'git stash'.
Signed-off-by Victoria Dye <[email protected]>--- Documentation/git-reset.txt | 3 +-- builtin/reset.c | 6 +++--- builtin/stash.c | 4 ++-- t/t7102-reset.sh | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-)Documentation/git-reset.txt +1
-2@@ -107,9 +107,8 @@ OPTIONS --quiet:: Be quiet, only report errors. ---refresh:: --no-refresh:: - Proactively refresh the index after a mixed reset. Enabled by default. + Disable refreshing the index after a mixed reset. --pathspec-from-file=<file>:: Pathspec is passed in `<file>` instead of commandline args. Ifbuiltin/reset.c +1
-1@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =-1 ; +int refresh =1 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 404
Quoted 7 lines
builtin/reset.c +2
-2@@ -400,8 +400,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)int intent_to_add =0 ;const struct option options[] = {OPT__QUIET (&quiet,N_ ("be quiet, only report errors" )), -OPT_BOOL (0 ,"refresh" , &refresh, -N_ ("skip refreshing the index after reset" )), +OPT_SET_INT (0 ,"no-refresh" , &refresh, +N_ ("skip refreshing the index after reset" ),0 ),
I'm confused why we need to change the option type here - am I missing something?
Best Wishes
Phillip
Re: [PATCH 1/4] reset: do not make '--quiet' disable index refresh
In reply to Phillip WoodQuoted 50 lines · Phillip Wood
Hi Victoria
Quoted 38 lines · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
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 <[email protected]>---
Documentation/git-reset.txt| 5 +----
builtin/reset.c | 7 ------- t/t7102-reset.sh | 32 +++++---------------------------3 files changed, 6 insertions(+), 38 deletions(-)Documentation/git-reset.txt +0
-0@@ -114,10 +114,7 @@ OPTIONS--no-refresh::
Proactively refresh the index after a mixed reset. If unspecified, the behavior falls back on thereset.refreshconfig option. If neither ---[no-]refreshnorreset.refreshare set, the default behavior is - decided by the--[no-]quietoption and/orreset.quietconfig. - If--quietis specified orreset.quietis set with no command-line - "quiet" setting, refresh is disabled. Otherwise, refresh is enabled. +--[no-]refreshnorreset.refreshare set, refresh is enabled. --pathspec-from-file=<file>::
Pathspec is passed in<file>instead of commandline args. Ifbuiltin/reset.c +0
-0@@ -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);Quoted 6 lines
- /*
- * 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?
Quoted 3 lines
Best Wishes
Phillip
Yes, thanks for catching that! It should be initialized to 1 in this patch (rather than later in patch 4).
Re: [PATCH 4/4] reset: deprecate '--refresh', leaving only '--no-refresh'
In reply to Phillip WoodQuoted 11 lines · Phillip Wood
Hi Victoria
Quoted 8 lines · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
The explicit '--refresh' option was needed in the past when '--quiet', 'reset.quiet', and/or 'reset.refresh' disabled the index refresh in 'reset --mixed'. Those options have since either been deprecated or made to always refresh the index by default, leaving only '--[no-]refresh' determining whether the index is refreshed or not.
Quoted 6 lines
Quoted 3 lines
Because there is nothing other than '--no-refresh' to disable index refresh, we do not need a '--refresh' option to counteract some other refresh disabling.
'--refresh' could be used to countermand a previous '--no-refresh' (typically when using an alias that includes '--no-refresh'). Usually we have '--foo' even when it is enabled by default e.g. 'commit --verify'. I think the code below does actually support '--refresh' as
parse_options()is smart enough to recognize option names beginning with '--no-' and creates an inverse option by removing the prefix rather than adding '--no-' as it normally does.
Makes sense, I didn't think of the alias use-case/generally wanting to counteract the negative version of the option. Thanks!
Quoted 39 lines
Quoted 39 lines
To ensure users don't use what is effectively a no-op, remove '--refresh' from the set of 'reset' options, as well as its usage in 'git stash'.
Signed-off-by Victoria Dye <[email protected]>---
Documentation/git-reset.txt| 3 +--
builtin/reset.c | 6 +++---
builtin/stash.c | 4 ++--
t/t7102-reset.sh | 5 ++---4 files changed, 8 insertions(+), 10 deletions(-)Documentation/git-reset.txt +0
-0@@ -107,9 +107,8 @@ OPTIONS--quiet::
Be quiet, only report errors.
---refresh::
--no-refresh::
- Proactively refresh the index after a mixed reset. Enabled by default. + Disable refreshing the index after a mixed reset. --pathspec-from-file=<file>::
Pathspec is passed in<file>instead of commandline args. Ifbuiltin/reset.c +1
-1@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb) int cmd_reset(int argc, const char **argv, const char *prefix) { int reset_type = NONE, update_ref_status = 0, quiet = 0; - int refresh = -1; + int refresh = 1; int patch_mode = 0, pathspec_file_nul = 0, unborn; const char *rev, *pathspec_from_file = NULL; struct object_id oid;@@ -400,8 +400,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) int intent_to_add = 0;
Quoted 9 lines
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 404
Quoted 6 lines
builtin/reset.c +2
-2const struct option options[] = { OPT__QUIET(&quiet, N_("be quiet, only report errors")), - OPT_BOOL(0, "refresh", &refresh, - N_("skip refreshing the index after reset")), + OPT_SET_INT(0, "no-refresh", &refresh, + N_("skip refreshing the index after reset"), 0),I'm confused why we need to change the option type here - am I missing something?
This was to explicitly prevent a user from specifying "--refresh", only allowing "--no-refresh". But, based on your earlier comments, there's still some value in having "--refresh", so I'll drop this patch entirely.
Quoted 4 lines
Best Wishes
Phillip
Re: [PATCH 3/4] reset: deprecate 'reset.refresh' config option
In reply to Phillip WoodQuoted 7 lines · Phillip Wood
Hi Victoria
Quoted 1 line · Victoria Dye via GitGitGadget
From: Victoria Dye <[email protected]>
Same concern about the title as the last patch
Agreed, I'll change it to "remove" in this and the previous patch.
Quoted 33 lines
Quoted 15 lines
Remove the 'reset.refresh' option, requiring that users explicitly specify '--no-refresh' if they want to skip refreshing the index.
The 'reset.refresh' option was introduced in
101cee42dd(reset: introduce --[no-]refresh option to --mixed, 2022-03-11) as a replacement for the refresh-skipping behavior originally controlled by 'reset.quiet'.Although 'reset.refresh=false' functionally served the same purpose as 'reset.quiet=true', it exposed [1] the fact that the existence of a global "skip refresh" option could potentially cause problems for users. Allowing a global config option to avoid refreshing the index forces scripts using 'git reset --mixed' to defensively use '--refresh' if index refresh is expected; if that option is missing, behavior of a script could vary from user-to-user without explanation.
Quoted 7 lines
Furthermore, globally disabling index refresh in 'reset --mixed' was initially devised as a passive performance improvement; since the introduction of the option, other changes have been made to Git (e.g., the sparse index) with a greater potential performance impact without sacrificing index correctness. Therefore, we can more aggressively err on the side of correctness and limit the cases of skipping index refresh to only when a user specifies the '--no-refresh' option.
Thanks for the well explained commit message
Quoted 9 lines
[1] https://lore.kernel.org/git/[email protected]/
Signed-off-by Victoria Dye <[email protected]>---
Documentation/git-reset.txt| 4 +---
builtin/reset.c | 4 +---
t/t7102-reset.sh | 14 ++------------3 files changed, 4 insertions(+), 18 deletions(-)
Quoted 14 lines
Quoted 11 lines
Documentation/git-reset.txt +0
-0@@ -109,9 +109,7 @@ OPTIONS--refresh::
--no-refresh::
- Proactively refresh the index after a mixed reset. If unspecified, the - behavior falls back on thereset.refreshconfig option. If neither ---[no-]refreshnorreset.refreshare set, refresh is enabled. + Proactively refresh the index after a mixed reset. Enabled by default."Proactively" seems a but superfluous if I'm being picky. There was no entry in the config man page for reset.refresh so we don't need to do anything there. The code changes below look good
Will update, thanks!
Quoted 52 lines
Best Wishes
Phillip
Quoted 46 lines
--pathspec-from-file=<file>::
Pathspec is passed in<file>instead of commandline args. Ifbuiltin/reset.c +0
-1@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) }; git_config(git_reset_config, NULL); - git_config_get_bool("reset.refresh", &refresh); argc = parse_options(argc, argv, prefix, options, git_reset_usage, PARSE_OPT_KEEP_DASHDASH);@@ -529,8 +528,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) t_delta_in_ms = (getnanotime() - t_begin) / 1000000; if (!quiet && advice_enabled(ADVICE_RESET_NO_REFRESH_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {advise(_("It took %.2f seconds to refresh the index after reset. You can use\n" - "'--no-refresh' to avoid this. Set the config setting reset.refresh to false\n" - "to make this the default."),
t_delta_in_ms/ 1000.0);
+ "'--no-refresh' to avoid this."),t_delta_in_ms/ 1000.0);
}
}
} else {t/t7102-reset.sh +0
-0@@ -493,19 +493,9 @@ test_expect_success '--mixed refreshes the index' ''
test_expect_success'--mixed --[no-]refresh sets refresh behavior' ' - # Verify that --[no-]refresh andreset.refreshcontrol index refresht/t7102-reset.sh +1
-6- - # Config setting - test_reset_refreshes_index "-c reset.refresh=true" && - ! test_reset_refreshes_index "-c reset.refresh=false" && - - # Command line option + # Verify that --[no-]refresh controls index refresh
test_reset_refreshes_index"" --refresh &&
- !test_reset_refreshes_index"" --no-refresh &&
-
- # Command line option overrides config setting
-test_reset_refreshes_index"-c reset.refresh=false" --refresh && - !test_reset_refreshes_index"-c reset.refresh=true" --no-refresh + !test_reset_refreshes_index"" --no-refresh
'
test_expect_success'--mixed preserves skip-worktree' '
v2 cover reset: make --no-refresh the only way to skip index refresh
In reply to Victoria Dye via GitGitGadgetMaintainer's note: this is based on vd/stash-silence-reset (specifically, 4b8b0f6fa2 (stash: make internal resets quiet and refresh index, 2022-03-15)).
----------------------------------------------------------------------------
This is a follow-up to the changes in vd/stash-silence-reset [1], in which index refreshing behavior was decoupled from log silencing in the '--quiet' option to 'git reset --mixed' by introducing a '--[no-]refresh' option and 'reset.refresh' config setting.
After some discussion [2] on the mailing list, both the backward-compatibility and use of global options in that series came into question:
* '--quiet' still skipped refresh if neither '--[no-]refresh' nor 'reset.refresh' were specified, meaning that users could still be left with an incorrect index state after reset.
* Having 'reset.quiet' and/or 'reset.refresh' potentially disable index refresh by default meant that developers would need to defensively add '--refresh' to all internal uses of 'git reset --mixed'. Without that option, different config setups could cause variability in index correctness from user to user.
In response, this series removes all methods of skipping index refresh in 'git reset --mixed' except for '--no-refresh' itself:
* Patch [1/3] removes the "fallback" behavior of 'reset.quiet' and '--quiet' implying '--no-refresh' if neither '--[no-]refresh' nor 'config.refresh' were specified. In other words, '--quiet' no longer does anything other than log silencing.
* Patch [2/3] removes 'reset.quiet', since its main use was to disable index refresh until that behavior was removed in [1/3].
* Patch [3/3] removes 'reset.refresh' to avoid users accidentally ending up with an incorrect index state after all resets as a result of a global setting's passive effects.
Changes since V1
================
* Dropped patch that removed '--refresh', again allowing both '--no-refresh' and '--refresh' as valid options.
* Updated documentation of "--refresh" option to remove unnecessary "proactively".
* Reworded commit titles to change "deprecate" to the more accurate "remove".
[1]
https://lore.kernel.org/git/[email protected]/
[2]
https://lore.kernel.org/git/[email protected]/
Thanks! -Victoria
Victoria Dye (3):
reset: do not make '--quiet' disable index refresh
reset: remove 'reset.quiet' config option
reset: remove 'reset.refresh' config option
Documentation/config.txt | 2 -- Documentation/config/reset.txt | 2 -- Documentation/git-reset.txt | 12 ++------- builtin/reset.c | 14 ++--------- contrib/scalar/scalar.c | 1 - t/t7102-reset.sh | 45 +++++----------------------------- 6 files changed, 10 insertions(+), 66 deletions(-) delete mode 100644 Documentation/config/reset.txt
base-commit: 877d90220e42b40cf5b899dc36a13c348220b54c
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1184%2Fvdye%2Freset%2Fclean-up-refresh-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1184/vdye/reset/clean-up-refresh-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1184
Range-diff vs v1:
1: f89e9b4ae24 ! 1: 1b607e0610b reset: do not make '--quiet' disable index refresh
@@ Commit message
behavior from '--quiet' because it is completely unrelated to the stated purpose of the option: "Be quiet, only report errors."
+ Helped-by: Phillip Wood <[email protected]>
## Documentation/git-reset.txt ##
@@ Documentation/git-reset.txt: OPTIONS
Pathspec is passed in <file> instead of commandline args. If
## builtin/reset.c ##
+@@ builtin/reset.c: static int git_reset_config(const char *var, const char *value, void *cb)
+ int cmd_reset(int argc, const char **argv, const char *prefix)
+ {
+ int reset_type = NONE, update_ref_status = 0, quiet = 0;
+- int refresh = -1;
++ int refresh = 1;
+ int patch_mode = 0, pathspec_file_nul = 0, unborn;
+ const char *rev, *pathspec_from_file = NULL;
+ struct object_id oid;
@@ builtin/reset.c: int cmd_reset(int argc, const char **argv, const char *prefix)
PARSE_OPT_KEEP_DASHDASH);
parse_args(&pathspec, argv, prefix, patch_mode, &rev);
2: d9bebd4b4e0 ! 2: a25aff3ac7c reset: deprecate 'reset.quiet' config option
@@ Metadata
Author: Victoria Dye <[email protected]>
## Commit message ##
- reset: deprecate 'reset.quiet' config option
+ reset: remove 'reset.quiet' config option
Remove the 'reset.quiet' config option, remove '--no-quiet' documentation in 'Documentation/git-reset.txt'. In 4c3abd0551 (reset: add new reset.quiet
3: ecd3296fd25 ! 3: 597aa82851c reset: deprecate 'reset.refresh' config option
@@ Metadata
Author: Victoria Dye <[email protected]>
## Commit message ##
- reset: deprecate 'reset.refresh' config option
+ reset: remove 'reset.refresh' config option
Remove the 'reset.refresh' option, requiring that users explicitly specify '--no-refresh' if they want to skip refreshing the index.
@@ Documentation/git-reset.txt: OPTIONS
- 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, refresh is enabled.
-+ Proactively refresh the index after a mixed reset. Enabled by default.
++ Refresh the index after a mixed reset. Enabled by default.
--pathspec-from-file=<file>::
Pathspec is passed in <file> instead of commandline args. If
4: dbb63c4caa8 < -: ----------- reset: deprecate '--refresh', leaving only '--no-refresh'
Signature · 1 line
gitgitgadget
PATCH v2 1/3 reset: do not make '--quiet' disable index refresh
From: Victoria Dye <[email protected]>
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."
--- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 9 +-------- t/t7102-reset.sh | 32 +++++--------------------------- 3 files changed, 7 insertions(+), 39 deletions(-)
Documentation/git-reset.txt +1 -4
@@ -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
builtin/reset.c +1 -8
@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =-1 ; +int refresh =1 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;
@@ -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" );
t/t7102-reset.sh +5 -27
@@ -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 &&
Signature · 1 line
gitgitgadget
PATCH v2 2/3 reset: remove 'reset.quiet' config option
In reply to Victoria Dye via GitGitGadgetFrom: Victoria Dye <[email protected]>
Remove the 'reset.quiet' config option, remove '--no-quiet' documentation in 'Documentation/git-reset.txt'. In 4c3abd0551 (reset: add new reset.quiet config setting, 2018-10-23), 'reset.quiet' was introduced as a way to globally change the default behavior of 'git reset --mixed' to skip index refresh.
However, now that '--quiet' does not affect index refresh, 'reset.quiet' would only serve to globally silence logging. This was not the original intention of the config setting, and there's no precedent for such a setting in other commands with a '--quiet' option, so it appears to be obsolete.
In addition to the options & its documentation, remove 'reset.quiet' from the recommended config for 'scalar'.
--- Documentation/config.txt | 2 -- Documentation/config/reset.txt | 2 -- Documentation/git-reset.txt | 5 +---- builtin/reset.c | 1 - contrib/scalar/scalar.c | 1 - t/t7102-reset.sh | 3 +-- 6 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 Documentation/config/reset.txt
Documentation/config.txt +0 -2
@@ -495,8 +495,6 @@ include::config/repack.txt[] include::config/rerere.txt[] -include::config/reset.txt[] - include::config/sendemail.txt[] include::config/sequencer.txt[]
Documentation/config/reset.txt deleted +0 -2
@@ -1,2 +0,0 @@ -reset.quiet:: - When set to true, 'git reset' will default to the '--quiet' option.
Documentation/git-reset.txt +1 -4
@@ -105,10 +105,7 @@ OPTIONS -q:: --quiet:: ---no-quiet:: - Be quiet, only report errors. The default behavior is set by the - `reset.quiet` config option. `--quiet` and `--no-quiet` will - override the default behavior. + Be quiet, only report errors. --refresh:: --no-refresh::
builtin/reset.c +0 -1
@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.quiet" , &quiet);git_config_get_bool ("reset.refresh" , &refresh); argc = parse_options(argc, argv, prefix, options, git_reset_usage,
contrib/scalar/scalar.c +0 -1
@@ -152,7 +152,6 @@ static int set_recommended_config(int reconfigure) { "pack.useBitmaps", "false", 1 }, { "pack.useSparse", "true", 1 }, { "receive.autoGC", "false", 1 }, - { "reset.quiet", "true", 1 }, { "feature.manyFiles", "false", 1 }, { "feature.experimental", "false", 1 }, { "fetch.unpackLimit", "1", 1 },
t/t7102-reset.sh +1 -2
@@ -488,8 +488,7 @@ test_expect_success '--mixed refreshes the index' ' # Verify default behavior (without --[no-]refresh or reset.refresh) test_reset_refreshes_index && - # With --quiet & reset.quiet - test_reset_refreshes_index "-c reset.quiet=true" && + # With --quiet test_reset_refreshes_index "" --quiet '
Signature · 1 line
gitgitgadget
PATCH v2 3/3 reset: remove 'reset.refresh' config option
In reply to Victoria Dye via GitGitGadgetFrom: Victoria Dye <[email protected]>
Remove the 'reset.refresh' option, requiring that users explicitly specify '--no-refresh' if they want to skip refreshing the index.
The 'reset.refresh' option was introduced in 101cee42dd (reset: introduce --[no-]refresh option to --mixed, 2022-03-11) as a replacement for the refresh-skipping behavior originally controlled by 'reset.quiet'.
Although 'reset.refresh=false' functionally served the same purpose as 'reset.quiet=true', it exposed [1] the fact that the existence of a global "skip refresh" option could potentially cause problems for users. Allowing a global config option to avoid refreshing the index forces scripts using 'git reset --mixed' to defensively use '--refresh' if index refresh is expected; if that option is missing, behavior of a script could vary from user-to-user without explanation.
Furthermore, globally disabling index refresh in 'reset --mixed' was initially devised as a passive performance improvement; since the introduction of the option, other changes have been made to Git (e.g., the sparse index) with a greater potential performance impact without sacrificing index correctness. Therefore, we can more aggressively err on the side of correctness and limit the cases of skipping index refresh to only when a user specifies the '--no-refresh' option.
[1] https://lore.kernel.org/git/[email protected]/
--- Documentation/git-reset.txt | 4 +--- builtin/reset.c | 4 +--- t/t7102-reset.sh | 14 ++------------ 3 files changed, 4 insertions(+), 18 deletions(-)
Documentation/git-reset.txt +1 -3
@@ -109,9 +109,7 @@ OPTIONS --refresh:: --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, refresh is enabled. + Refresh the index after a mixed reset. Enabled by default. --pathspec-from-file=<file>:: Pathspec is passed in `<file>` instead of commandline args. If
builtin/reset.c +1 -3
@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) };git_config (git_reset_config,NULL ); -git_config_get_bool ("reset.refresh" , &refresh); argc =parse_options (argc, argv, prefix, options, git_reset_usage,PARSE_OPT_KEEP_DASHDASH );
@@ -529,8 +528,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) t_delta_in_ms = (getnanotime () - t_begin) /1000000 ;if (!quiet &&advice_enabled (ADVICE_RESET_NO_REFRESH_WARNING ) && t_delta_in_ms >REFRESH_INDEX_DELAY_WARNING_IN_MS ) {advise (_ ("It took %.2f seconds to refresh the index after reset. You can use\n" -"'--no-refresh' to avoid this. Set the config setting reset.refresh to false\n" -"to make this the default." ), t_delta_in_ms /1000.0 ); +"'--no-refresh' to avoid this." ), t_delta_in_ms /1000.0 ); } } }else {
t/t7102-reset.sh +2 -12
@@ -493,19 +493,9 @@ test_expect_success '--mixed refreshes the index' ' ' test_expect_success '--mixed --[no-]refresh sets refresh behavior' ' - # Verify that --[no-]refresh and `reset.refresh` control index refresh - - # Config setting - test_reset_refreshes_index "-c reset.refresh=true" && - ! test_reset_refreshes_index "-c reset.refresh=false" && - - # Command line option + # Verify that --[no-]refresh controls index refresh test_reset_refreshes_index "" --refresh && - ! test_reset_refreshes_index "" --no-refresh && - - # Command line option overrides config setting - test_reset_refreshes_index "-c reset.refresh=false" --refresh && - ! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh + ! test_reset_refreshes_index "" --no-refresh ' test_expect_success '--mixed preserves skip-worktree' '
Signature · 1 line
gitgitgadget
Quoted 8 lines · Victoria Dye via GitGitGadget
This is a follow-up to the changes in vd/stash-silence-reset [1], in which index refreshing behavior was decoupled from log silencing in the '--quiet' option to 'git reset --mixed' by introducing a '--[no-]refresh' option and 'reset.refresh' config setting.
Changes since V1
================
Quoted 6 lines
* Dropped patch that removed '--refresh', again allowing both '--no-refresh' and '--refresh' as valid options.
* Updated documentation of "--refresh" option to remove unnecessary "proactively".
* Reworded commit titles to change "deprecate" to the more accurate "remove".
I read through the patches in v2 along with the discussion from v1 and the changes due to that discussion. This version looks good to me.
Thanks,
-Stolee
Quoted 5 lines · Victoria Dye via GitGitGadget
Changes since V1
================* Dropped patch that removed '--refresh', again allowing both '--no-refresh' and '--refresh' as valid options.
Makes sense. Thanks for suggesting this, Phillip.
Quoted 2 lines
* Updated documentation of "--refresh" option to remove unnecessary "proactively".
OK.
Quoted 2 lines
* Reworded commit titles to change "deprecate" to the more accurate "remove".
OK.
Will queue. Thanks.
Hi Victoria
Quoted 5 lines · Victoria Dye via GitGitGadget
Changes since V1
================* Dropped patch that removed '--refresh', again allowing both '--no-refresh' and '--refresh' as valid options.
I should have been clearer in my comments that I think changing the option name no '--no-refresh' whilst retaining '--refresh' is worthwhile. '--no-refresh' is the form that users will want most of the time and changing the option name means that the useful version will be shown by "reset -h".
The range-diff for the other changes looks good
Best Wishes
Phillip
Quoted 5 lines · Phillip Wood
I should have been clearer in my comments that I think changing the option name no '--no-refresh' whilst retaining '--refresh' is worthwhile. '--no-refresh' is the form that users will want most of the time and changing the option name means that the useful version will be shown by "reset -h".
I am OK with it shown as "--[no-]refresh" or even "--refresh" alone, as long as the description describes the "refresh" behaviour and makes it clear that it is the default, with the expectation that the users know from other boolean options that "--option" listed in "-h" would naturally take "--no-option".
But as posted,
$ rungit seen reset -h 2>&1 | grep refresh
--refresh skip refreshing the index after resetthe explanation given is for "--no-refresh" (which is wrong), so we'd need some fix in the area. We could rephrase it to read
--refresh refresh the index after reset (default)
but as you suggested, I think mimicking how existing commands with "--no-<option>" are shown, e.g. builtlin/update-ref.c does "--no-deref",
$ git update-ref -h 2>&1 | grep deref
--no-deref update <refname> not the one it points to
$ git grep 'OPT_BOOL.*"no-deref"'
builtin/update-ref.c: OPT_BOOL( 0 , "no-deref", &no_deref,would be a good approach.
Quoted 1 line
The range-diff for the other changes looks good
Thanks.
#leftoverbit: we may want to discuss if it is a good idea to teach OPT_BOOL() to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".
Quoted 11 lines · Junio C Hamano
... as you suggested, I think mimicking how existing commands with "--no-<option>" are shown, e.g.
builtlin/update-ref.cdoes "--no-deref",$ git update-ref -h 2>&1 | grep deref --no-deref update <refname> not the one it points to $ git grep 'OPT_BOOL.*"no-deref"' builtin/update-ref.c: OPT_BOOL( 0 , "no-deref", &no_deref,would be a good approach.
Quoted 7 lines
Quoted 1 line
The range-diff for the other changes looks good
Thanks.
#leftoverbit: we may want to discuss if it is a good idea to teach
OPT_BOOL()to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".
Unfortunately, I merged these already to 'next' before seeing your comment, so we'd need to go incremental.
How about this?
----- >8 --------- >8 --------- >8 --------- >8 -----
Subject: [PATCH] reset: show --no-refresh in the short-help
In the short help output from "git reset -h", the recently added "--[no-]refresh" option is shown like so:
--refresh skip refreshing the index after reset
which explains what happens when the option is given in the negative form, i.e. "--no-refresh". We could rephrase the explanation to read "refresh the index after reset (default)" to hint that the user can say "--no-refresh" to override the default, but listing the "--no-refresh" form in the list of options would be more helpful.
--- builtin/reset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
builtin/reset.c +3 -3
@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =1 ; +int no_refresh =0 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;
@@ -400,7 +400,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)int intent_to_add =0 ;const struct option options[] = {OPT__QUIET (&quiet,N_ ("be quiet, only report errors" )), -OPT_BOOL (0 ,"refresh" , &refresh, +OPT_BOOL (0 ,"no-refresh" , &no_refresh,N_ ("skip refreshing the index after reset" )),OPT_SET_INT (0 ,"mixed" , &reset_type,N_ ("reset HEAD and index" ),MIXED ),
@@ -519,7 +519,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)if (read_from_tree (&pathspec, &oid, intent_to_add))return 1 ; the_index.updated_skipworktree =1 ; -if (refresh &&get_git_work_tree ()) { +if (!no_refresh &&get_git_work_tree ()) {uint64_t t_begin, t_delta_in_ms; t_begin =getnanotime ();
Quoted 70 lines · Junio C Hamano
Quoted 11 lines · Junio C Hamano
... as you suggested, I think mimicking how existing commands with "--no-<option>" are shown, e.g.
builtlin/update-ref.cdoes "--no-deref",$ git update-ref -h 2>&1 | grep deref --no-deref update <refname> not the one it points to $ git grep 'OPT_BOOL.*"no-deref"' builtin/update-ref.c: OPT_BOOL( 0 , "no-deref", &no_deref,would be a good approach.
Quoted 7 lines
Quoted 1 line
The range-diff for the other changes looks good
Thanks.
#leftoverbit: we may want to discuss if it is a good idea to teach
OPT_BOOL()to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".Unfortunately, I merged these already to 'next' before seeing your comment, so we'd need to go incremental.
How about this?
----- >8 --------- >8 --------- >8 --------- >8 -----
Subject: [PATCH] reset: show --no-refresh in the short-helpIn the short help output from "git reset -h", the recently added "--[no-]refresh" option is shown like so:
--refresh skip refreshing the index after reset
which explains what happens when the option is given in the negative form, i.e. "--no-refresh". We could rephrase the explanation to read "refresh the index after reset (default)" to hint that the user can say "--no-refresh" to override the default, but listing the "--no-refresh" form in the list of options would be more helpful.
Helped-by Phillip Wood <[email protected]>Signed-off-by Junio C Hamano <[email protected]>--- builtin/reset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)builtin/reset.c +2
-2@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =1 ; +int no_refresh =0 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;@@ -400,7 +400,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)int intent_to_add =0 ;const struct option options[] = {OPT__QUIET (&quiet,N_ ("be quiet, only report errors" )), -OPT_BOOL (0 ,"refresh" , &refresh, +OPT_BOOL (0 ,"no-refresh" , &no_refresh,N_ ("skip refreshing the index after reset" )),OPT_SET_INT (0 ,"mixed" , &reset_type,N_ ("reset HEAD and index" ),MIXED ),
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 525
Quoted 8 lines
builtin/reset.c +1
-1@@ -519,7 +519,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)if (read_from_tree (&pathspec, &oid, intent_to_add))return 1 ; the_index.updated_skipworktree =1 ; -if (refresh &&get_git_work_tree ()) { +if (!no_refresh &&get_git_work_tree ()) {uint64_t t_begin, t_delta_in_ms; t_begin =getnanotime ();
This looks good to me, and it's passing all of the relevant tests. Thank you both for your help with this!
Quoted 78 lines · Victoria Dye
Quoted 77 lines · Junio C Hamano
Quoted 11 lines · Junio C Hamano
... as you suggested, I think mimicking how existing commands with "--no-<option>" are shown, e.g.
builtlin/update-ref.cdoes "--no-deref",$ git update-ref -h 2>&1 | grep deref --no-deref update <refname> not the one it points to $ git grep 'OPT_BOOL.*"no-deref"' builtin/update-ref.c: OPT_BOOL( 0 , "no-deref", &no_deref,would be a good approach.
Quoted 7 lines
Quoted 1 line
The range-diff for the other changes looks good
Thanks.
#leftoverbit: we may want to discuss if it is a good idea to teach
OPT_BOOL()to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".Unfortunately, I merged these already to 'next' before seeing your comment, so we'd need to go incremental.
How about this?
----- >8 --------- >8 --------- >8 --------- >8 -----
Subject: [PATCH] reset: show --no-refresh in the short-helpIn the short help output from "git reset -h", the recently added "--[no-]refresh" option is shown like so:
--refresh skip refreshing the index after reset
which explains what happens when the option is given in the negative form, i.e. "--no-refresh". We could rephrase the explanation to read "refresh the index after reset (default)" to hint that the user can say "--no-refresh" to override the default, but listing the "--no-refresh" form in the list of options would be more helpful.
Helped-by Phillip Wood <[email protected]>Signed-off-by Junio C Hamano <[email protected]>--- builtin/reset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)builtin/reset.c +3
-3@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)int cmd_reset (int argc,const char **argv,const char *prefix) {int reset_type =NONE , update_ref_status =0 , quiet =0 ; -int refresh =1 ; +int no_refresh =0 ;int patch_mode =0 , pathspec_file_nul =0 , unborn;const char *rev, *pathspec_from_file =NULL ;struct object_id oid;@@ -400,7 +400,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)int intent_to_add =0 ;const struct option options[] = {OPT__QUIET (&quiet,N_ ("be quiet, only report errors" )), -OPT_BOOL (0 ,"refresh" , &refresh, +OPT_BOOL (0 ,"no-refresh" , &no_refresh,N_ ("skip refreshing the index after reset" )),OPT_SET_INT (0 ,"mixed" , &reset_type,N_ ("reset HEAD and index" ),MIXED ),@@ -519,7 +519,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)if (read_from_tree (&pathspec, &oid, intent_to_add))return 1 ; the_index.updated_skipworktree =1 ; -if (refresh &&get_git_work_tree ()) { +if (!no_refresh &&get_git_work_tree ()) {uint64_t t_begin, t_delta_in_ms;
Quoted 4 lines
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 525
Quoted 1 line
builtin/reset.c +0
-0t_begin =getnanotime ();This looks good to me, and it's passing all of the relevant tests. Thank you both for your help with this!
OK, will queue this on top.
Thanks.
Quoted 4 lines · Junio C Hamano
Quoted 3 lines · Junio C Hamano
#leftoverbit: we may want to discuss if it is a good idea to teach
OPT_BOOL()to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".
Good idea!
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 404
Quoted 8 lines
Unfortunately, I merged these already to 'next' before seeing your comment, so we'd need to go incremental.
How about this?
builtin/reset.c +1
-1-OPT_BOOL (0 ,"refresh" , &refresh, +OPT_BOOL (0 ,"no-refresh" , &no_refresh, N_("skip refreshing the index after reset")),
I'm pleasantly surprised that this still allows --refresh (in addition to --no-no-refresh). So, the only meaningful functional change is indeed the -h output.
Thanks,
-Stolee
Quoted 13 lines · Derrick Stolee
Quoted 4 lines · Junio C Hamano
Quoted 3 lines · Junio C Hamano
#leftoverbit: we may want to discuss if it is a good idea to teach
OPT_BOOL()to list "--[no-]<option>" in "git cmd -h", instead of just "--<option>".Good idea!
Quoted 4 lines
Unfortunately, I merged these already to 'next' before seeing your comment, so we'd need to go incremental.
How about this?
Quoted 7 lines
builtin/reset.c int cmd_reset(int argc, const char **argv, const char *prefix) · line 404
Quoted 3 lines
builtin/reset.c +1
-1-OPT_BOOL (0 ,"refresh" , &refresh, +OPT_BOOL (0 ,"no-refresh" , &no_refresh, N_("skip refreshing the index after reset")),I'm pleasantly surprised that this still allows --refresh (in addition to --no-no-refresh). So, the only meaningful functional change is indeed the -h output.
Yeah, it is a pleasant easter egg surprise that --refresh is taken as the opposite but its cousin that we allow --no-no-refresh is somehow questionably ugly, albeit it does not hurt anybody, except for purists who would certainly complain that --no-no-no-refresh is not understood.