reset: introduce --[no-]refresh option to --mixed
commitfd56fba97f26bf668749207efd6a45aee2e2f57c
authorVictoria Dye <vdye@github.com>
Tue, 15 Mar 2022 01:49:39 +0000 (15 01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Mar 2022 01:51:56 +0000 (14 18:51 -0700)
treee13d2c651f2e61f146d83cbafa209577ab4b0def
parente86ec71d20d14861e4a3d047800d3ea3099c946d
reset: introduce --[no-]refresh option to --mixed

Add a new --[no-]refresh option that is intended to explicitly determine
whether a mixed reset should end in an index refresh.

Starting at 9ac8125d1a (reset: don't compute unstaged changes after reset
when --quiet, 2018-10-23), using the '--quiet' option results in skipping
the call to 'refresh_index(...)' at the end of a mixed reset with the goal
of improving performance. However, by coupling behavior that modifies the
index with the option that silences logs, there is no way for users to have
one without the other (i.e., silenced logs with a refreshed index) without
incurring the overhead of a separate call to 'git update-index --refresh'.
Furthermore, there is minimal user-facing documentation indicating that
--quiet skips the index refresh, potentially leading to unexpected issues
executing commands after 'git reset --quiet' that do not themselves refresh
the index (e.g., internals of 'git stash', 'git read-tree').

To mitigate these issues, '--[no-]refresh' and 'reset.refresh' are
introduced to provide a dedicated mechanism for refreshing the index. When
either is set, '--quiet' and 'reset.quiet' revert to controlling only
whether logs are silenced and do not affect index refresh.

Helped-by: Derrick Stolee <derrickstolee@github.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-reset.txt
builtin/reset.c
t/t7102-reset.sh