git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 0/3] reset: make --no-refresh the only way to skip index refresh

From
Victoria Dye <vdye@github.com>
Date
Mar 24, 2022, 18:01 UTC
Message-ID
<fb16c818-288f-aa8b-cafd-cd418d84f194@github.com>
In-Reply-To
<xmqq7d8jjlwp.fsf@gitster.g>
Junio C Hamano wrote:
Show 78 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> ... 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.
>>
>>> 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.
> 
> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/reset.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git c/builtin/reset.c w/builtin/reset.c
> index 1d89faef5e..344fff8f3a 100644
> --- c/builtin/reset.c
> +++ w/builtin/reset.c
> @@ -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();

This looks good to me, and it's passing all of the relevant tests. Thank you both for your help with this!

Previous: Junio C HamanoNext: Junio C Hamano
Message 22 of 25 in “reset: make --no-refresh the only way to skip index refresh”
  1. 0/4 reset: make --no-refresh the only way to skip index refreshVictoria Dye via GitGitGadget, Mar 21, 2022
  2. 2/4 reset: deprecate 'reset.quiet' config optionVictoria Dye via GitGitGadget, Mar 21, 2022
  3. Phillip WoodMar 23, 2022
  4. 1/4 reset: do not make '--quiet' disable index refreshVictoria Dye via GitGitGadget, Mar 21, 2022
  5. Phillip WoodMar 23, 2022
  6. Victoria DyeMar 23, 2022
  7. 3/4 reset: deprecate 'reset.refresh' config optionVictoria Dye via GitGitGadget, Mar 21, 2022
  8. Phillip WoodMar 23, 2022
  9. Victoria DyeMar 23, 2022
  10. 4/4 reset: deprecate '--refresh', leaving only '--no-refresh'Victoria Dye via GitGitGadget, Mar 21, 2022
  11. Phillip WoodMar 23, 2022
  12. Victoria DyeMar 23, 2022
  13. 0/3 reset: make --no-refresh the only way to skip index refreshVictoria Dye via GitGitGadget, Mar 23, 2022
  14. 1/3 reset: do not make '--quiet' disable index refreshVictoria Dye via GitGitGadget, Mar 23, 2022
  15. 2/3 reset: remove 'reset.quiet' config optionVictoria Dye via GitGitGadget, Mar 23, 2022
  16. 3/3 reset: remove 'reset.refresh' config optionVictoria Dye via GitGitGadget, Mar 23, 2022
  17. Derrick StoleeMar 23, 2022
  18. Junio C HamanoMar 23, 2022
  19. Phillip WoodMar 24, 2022
  20. Junio C HamanoMar 24, 2022
  21. Junio C HamanoMar 24, 2022
  22. Victoria DyeMar 24, 2022
  23. Junio C HamanoMar 24, 2022
  24. Derrick StoleeMar 25, 2022
  25. Junio C HamanoMar 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.