]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/stash.c
Merge branch 'rs/column-use-utf8-strnwidth'
[thirdparty/git.git] / builtin / stash.c
index b5a301f24d7a5f8b0a5f7d51703ca4cf38e2109c..4e806176b0828b65cf405492ca2cd2d157e3fc4a 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))
@@ -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);
        }
@@ -1129,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)
@@ -1290,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;
        }
@@ -1383,7 +1392,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;