X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=builtin%2Fstash.c;h=d913487a43f913bc4ecb59c3f4739ee9b56ada79;hp=56f3b551e4af71c0ea1a82c676a24617f8234eaf;hb=57b530125e022de79f5f0b208bc0a5ee67c18b77;hpb=4a58c3d7f7a83ebcd4ede635871cab7be24f7f3f diff --git a/builtin/stash.c b/builtin/stash.c index 56f3b551e4..d913487a43 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -396,7 +396,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, const struct object_id *bases[1]; read_cache_preload(NULL); - if (refresh_cache(REFRESH_QUIET)) + if (refresh_and_write_cache(REFRESH_QUIET, 0, 0)) return -1; if (write_cache_as_tree(&c_tree, 0, NULL)) @@ -427,6 +427,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, return error(_("could not save index tree")); reset_head(); + discard_cache(); + read_cache(); } } @@ -485,7 +487,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, } if (quiet) { - if (refresh_cache(REFRESH_QUIET)) + if (refresh_and_write_cache(REFRESH_QUIET, 0, 0)) warning("could not refresh index"); } else { struct child_process cp = CHILD_PROCESS_INIT; @@ -497,6 +499,10 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, */ cp.git_cmd = 1; cp.dir = prefix; + argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s", + absolute_path(get_git_work_tree())); + argv_array_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s", + absolute_path(get_git_dir())); argv_array_push(&cp.args, "status"); run_command(&cp); } @@ -1130,7 +1136,10 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b prepare_fallback_ident("git stash", "git@stash"); read_cache_preload(NULL); - refresh_cache(REFRESH_QUIET); + if (refresh_and_write_cache(REFRESH_QUIET, 0, 0) < 0) { + ret = -1; + goto done; + } if (get_oid("HEAD", &info->b_commit)) { if (!quiet) @@ -1291,7 +1300,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q free(ps_matched); } - if (refresh_cache(REFRESH_QUIET)) { + if (refresh_and_write_cache(REFRESH_QUIET, 0, 0)) { ret = -1; goto done; } @@ -1384,7 +1393,7 @@ 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; argv_array_pushl(&cp.args, "reset", "--hard", "-q", - NULL); + "--no-recurse-submodules", NULL); if (run_command(&cp)) { ret = -1; goto done;