aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/stash.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:08 -0700
committerJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:08 -0700
commita2fc9c3c404f2ef6384281e3a0fe824a8b0049bb (patch)
treed80c761657c80456b9669f58c6375545b217c515 /builtin/stash.c
parent47c52b2dada2d7223cfc8927ae7909dba27579a2 (diff)
parent758b4d2be8c009a07dfa86d8cafdf1375905ab45 (diff)
downloadgit-a2fc9c3c404f2ef6384281e3a0fe824a8b0049bb.tar.gz
Merge branch 'jc/stash-drop'
"git stash drop" is reimplemented as an internal call to reflog_delete() function, instead of invoking "git reflog delete" via run_command() API. * jc/stash-drop: stash: call reflog_delete() in reflog.c reflog: libify delete reflog function and helpers stash: add tests to ensure reflog --rewrite --updatref behavior
Diffstat (limited to 'builtin/stash.c')
-rw-r--r--builtin/stash.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index 3e8af210fd..242e73cbb0 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -17,6 +17,7 @@
#include "diffcore.h"
#include "exec-cmd.h"
#include "entry.h"
+#include "reflog.h"
#define INCLUDE_ALL_FILES 2
@@ -634,20 +635,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));