reset: do not make '--quiet' disable index refresh

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." Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Victoria Dye committed Mar 23, 2022 at 18:17 UTC 45bf76284b40856e47e8809e952167f0316b8a99
3 files changed +7 -39
Documentation/git-reset.txt
+1 -4
@@ -114,10 +114,7 @@ OPTIONS
114 --no-refresh::
115 Proactively refresh the index after a mixed reset. If unspecified, the
116 behavior falls back on the `reset.refresh` config option. If neither
117 - `--[no-]refresh` nor `reset.refresh` are set, the default behavior is
118 - decided by the `--[no-]quiet` option and/or `reset.quiet` config.
119 - If `--quiet` is specified or `reset.quiet` is set with no command-line
120 - "quiet" setting, refresh is disabled. Otherwise, refresh is enabled.
117 + `--[no-]refresh` nor `reset.refresh` are set, refresh is enabled.
118
119 --pathspec-from-file=<file>::
120 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)
392 int cmd_reset(int argc, const char **argv, const char *prefix)
393 {
394 int reset_type = NONE, update_ref_status = 0, quiet = 0;
395 - int refresh = -1;
395 + int refresh = 1;
396 int patch_mode = 0, pathspec_file_nul = 0, unborn;
397 const char *rev, *pathspec_from_file = NULL;
398 struct object_id oid;
@@ -430,13 +430,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
430 PARSE_OPT_KEEP_DASHDASH);
431 parse_args(&pathspec, argv, prefix, patch_mode, &rev);
432
433 - /*
434 - * If refresh is completely unspecified (either by config or by command
435 - * line option), decide based on 'quiet'.
436 - */
437 - if (refresh < 0)
438 - refresh = !quiet;
439 -
433 if (pathspec_from_file) {
434 if (patch_mode)
435 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 () {
485 }
486
487 test_expect_success '--mixed refreshes the index' '
488 - # Verify default behavior (with no config settings or command line
489 - # options)
490 - test_reset_refreshes_index
491 -'
492 -test_expect_success '--mixed --[no-]quiet sets default refresh behavior' '
493 - # Verify that --[no-]quiet and `reset.quiet` (without --[no-]refresh)
494 - # determine refresh behavior
495 -
496 - # Config setting
497 - ! test_reset_refreshes_index "-c reset.quiet=true" &&
498 - test_reset_refreshes_index "-c reset.quiet=false" &&
499 -
500 - # Command line option
501 - ! test_reset_refreshes_index "" --quiet &&
502 - test_reset_refreshes_index "" --no-quiet &&
488 + # Verify default behavior (without --[no-]refresh or reset.refresh)
489 + test_reset_refreshes_index &&
490
504 - # Command line option overrides config setting
505 - ! test_reset_refreshes_index "-c reset.quiet=false" --quiet &&
506 - test_reset_refreshes_index "-c reset.refresh=true" --no-quiet
491 + # With --quiet & reset.quiet
492 + test_reset_refreshes_index "-c reset.quiet=true" &&
493 + test_reset_refreshes_index "" --quiet
494 '
495
496 test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
@@ -522,15 +509,6 @@ test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
509 ! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh
510 '
511
525 -test_expect_success '--mixed --refresh overrides --quiet refresh behavior' '
526 - # Verify that *both* --refresh and `reset.refresh` override the
527 - # default non-refresh behavior of --quiet
528 - test_reset_refreshes_index "" "--quiet --refresh" &&
529 - test_reset_refreshes_index "-c reset.quiet=true" --refresh &&
530 - test_reset_refreshes_index "-c reset.refresh=true" --quiet &&
531 - test_reset_refreshes_index "-c reset.refresh=true -c reset.quiet=true"
532 -'
533 -
512 test_expect_success '--mixed preserves skip-worktree' '
513 echo 123 >>file2 &&
514 git add file2 &&