]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/stash.c
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / builtin / stash.c
index 3e8af210fdee6e5901497e5c572d8bc4da23502a..0c7b6a95882d9405e3cdf4a8d3d2d251dc0588db 100644 (file)
@@ -16,7 +16,7 @@
 #include "log-tree.h"
 #include "diffcore.h"
 #include "exec-cmd.h"
-#include "entry.h"
+#include "reflog.h"
 
 #define INCLUDE_ALL_FILES 2
 
@@ -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);
 }
@@ -634,20 +634,9 @@ static int reflog_is_empty(const char *refname)
 
 static int do_drop_stash(struct stash_info *info, int quiet)
 {
-       int ret;
-       struct child_process cp_reflog = CHILD_PROCESS_INIT;
-
-       /*
-        * reflog does not provide a simple function for deleting refs. One will
-        * need to be added to avoid implementing too much reflog code here
-        */
-
-       cp_reflog.git_cmd = 1;
-       strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
-                    "--rewrite", NULL);
-       strvec_push(&cp_reflog.args, info->revision.buf);
-       ret = run_command(&cp_reflog);
-       if (!ret) {
+       if (!reflog_delete(info->revision.buf,
+                          EXPIRE_REFLOGS_REWRITE | EXPIRE_REFLOGS_UPDATE_REF,
+                          0)) {
                if (!quiet)
                        printf_ln(_("Dropped %s (%s)"), info->revision.buf,
                                  oid_to_hex(&info->w_commit));
@@ -1633,7 +1622,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;