Skip to content

Commit 45bf762

Browse files
vdyegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4b8b0f6 commit 45bf762

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

Documentation/git-reset.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ OPTIONS
114114
--no-refresh::
115115
Proactively refresh the index after a mixed reset. If unspecified, the
116116
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.
121118

122119
--pathspec-from-file=<file>::
123120
Pathspec is passed in `<file>` instead of commandline args. If

builtin/reset.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int git_reset_config(const char *var, const char *value, void *cb)
392392
int cmd_reset(int argc, const char **argv, const char *prefix)
393393
{
394394
int reset_type = NONE, update_ref_status = 0, quiet = 0;
395-
int refresh = -1;
395+
int refresh = 1;
396396
int patch_mode = 0, pathspec_file_nul = 0, unborn;
397397
const char *rev, *pathspec_from_file = NULL;
398398
struct object_id oid;
@@ -430,13 +430,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
430430
PARSE_OPT_KEEP_DASHDASH);
431431
parse_args(&pathspec, argv, prefix, patch_mode, &rev);
432432

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-
440433
if (pathspec_from_file) {
441434
if (patch_mode)
442435
die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--patch");

t/t7102-reset.sh

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -485,25 +485,12 @@ test_reset_refreshes_index () {
485485
}
486486

487487
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 &&
503490
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
507494
'
508495

509496
test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
@@ -522,15 +509,6 @@ test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
522509
! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh
523510
'
524511

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-
534512
test_expect_success '--mixed preserves skip-worktree' '
535513
echo 123 >>file2 &&
536514
git add file2 &&

0 commit comments

Comments
 (0)