summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2022-03-15 01:49:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-03-15 01:51:56 (GMT)
commit4b8b0f6fa2778c1f9c373620e3f07787543914c6 (patch)
tree21128eb8abbfbc88122726b8ec7cfff34c469a1b /builtin
parentd492abb0ae4a00c5647189b22f7c130fb364e700 (diff)
downloadgit-4b8b0f6fa2778c1f9c373620e3f07787543914c6.zip
git-4b8b0f6fa2778c1f9c373620e3f07787543914c6.tar.gz
git-4b8b0f6fa2778c1f9c373620e3f07787543914c6.tar.bz2
stash: make internal resets quiet and refresh index
Add the options '-q' and '--refresh' to the 'git reset' executed in 'reset_head()', and '--refresh' to the 'git reset -q' executed in 'do_push_stash(...)'. 'stash' is implemented such that git commands invoked as part of it (e.g., 'clean', 'read-tree', 'reset', etc.) have their informational output silenced. However, the 'reset' in 'reset_head()' is *not* called with '-q', leading to the potential for a misleading printout from 'git stash apply --index' if the stash included a removed file: Unstaged changes after reset: D <deleted file> Not only is this confusing in its own right (since, after the reset, 'git stash' execution would stage the deletion in the index), it would be printed even when the stash was applied with the '-q' option. As a result, the messaging is removed entirely by calling 'git status' with '-q'. Additionally, because the default behavior of 'git reset -q' is to skip refreshing the index, but later operations in 'git stash' subcommands expect a non-stale index, enable '--refresh' as well. 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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/stash.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index 3e8af21..91407d9 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -310,7 +310,7 @@ static int reset_head(void)
* API for resetting.
*/
cp.git_cmd = 1;
- strvec_push(&cp.args, "reset");
+ strvec_pushl(&cp.args, "reset", "--quiet", "--refresh", NULL);
return run_command(&cp);
}
@@ -1633,7 +1633,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
struct child_process cp = CHILD_PROCESS_INIT;
cp.git_cmd = 1;
- strvec_pushl(&cp.args, "reset", "-q", "--", NULL);
+ strvec_pushl(&cp.args, "reset", "-q", "--refresh", "--",
+ NULL);
add_pathspecs(&cp.args, ps);
if (run_command(&cp)) {
ret = -1;