]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/stash.c
Merge branch 'en/merge-recursive-cleanup'
[thirdparty/git.git] / builtin / stash.c
index 4aa47785f94ff5e414fafb795d527e15c4ce2bae..bb4f6d8d762d833e6cc15accf70f2680dd7af721 100644 (file)
@@ -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))
@@ -487,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;
@@ -499,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);
        }
@@ -1131,7 +1135,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)
@@ -1292,7 +1299,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;
        }