Skip to content

Commit 7cff676

Browse files
vdyegitster
authored andcommitted
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. The 'reset.refresh' option was introduced in 101cee4 (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]/ Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2efc9b8 commit 7cff676

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

Documentation/git-reset.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ OPTIONS
109109

110110
--refresh::
111111
--no-refresh::
112-
Proactively refresh the index after a mixed reset. If unspecified, the
113-
behavior falls back on the `reset.refresh` config option. If neither
114-
`--[no-]refresh` nor `reset.refresh` are set, refresh is enabled.
112+
Refresh the index after a mixed reset. Enabled by default.
115113

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

builtin/reset.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
423423
};
424424

425425
git_config(git_reset_config, NULL);
426-
git_config_get_bool("reset.refresh", &refresh);
427426

428427
argc = parse_options(argc, argv, prefix, options, git_reset_usage,
429428
PARSE_OPT_KEEP_DASHDASH);
@@ -529,8 +528,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
529528
t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
530529
if (!quiet && advice_enabled(ADVICE_RESET_NO_REFRESH_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
531530
advise(_("It took %.2f seconds to refresh the index after reset. You can use\n"
532-
"'--no-refresh' to avoid this. Set the config setting reset.refresh to false\n"
533-
"to make this the default."), t_delta_in_ms / 1000.0);
531+
"'--no-refresh' to avoid this."), t_delta_in_ms / 1000.0);
534532
}
535533
}
536534
} else {

t/t7102-reset.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,19 +493,9 @@ test_expect_success '--mixed refreshes the index' '
493493
'
494494

495495
test_expect_success '--mixed --[no-]refresh sets refresh behavior' '
496-
# Verify that --[no-]refresh and `reset.refresh` control index refresh
497-
498-
# Config setting
499-
test_reset_refreshes_index "-c reset.refresh=true" &&
500-
! test_reset_refreshes_index "-c reset.refresh=false" &&
501-
502-
# Command line option
496+
# Verify that --[no-]refresh controls index refresh
503497
test_reset_refreshes_index "" --refresh &&
504-
! test_reset_refreshes_index "" --no-refresh &&
505-
506-
# Command line option overrides config setting
507-
test_reset_refreshes_index "-c reset.refresh=false" --refresh &&
508-
! test_reset_refreshes_index "-c reset.refresh=true" --no-refresh
498+
! test_reset_refreshes_index "" --no-refresh
509499
'
510500

511501
test_expect_success '--mixed preserves skip-worktree' '

0 commit comments

Comments
 (0)