diff options
| author | John Cai <johncai86@gmail.com> | 2022-03-02 22:27:24 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-03-02 15:24:47 -0800 |
| commit | 758b4d2be8c009a07dfa86d8cafdf1375905ab45 (patch) | |
| tree | e742b3f2155252359ccc0516168f0c4ea6fe2477 | |
| parent | 7d3d226e700904d6fbf3d9a1b351ebeb02f2cf04 (diff) | |
| download | git-758b4d2be8c009a07dfa86d8cafdf1375905ab45.tar.xz | |
stash: call reflog_delete() in reflog.c
Now that cmd_reflog_delete has been libified an exported it into a new
reflog.c library so we can call it directly from builtin/stash.c. This
not only gives us a performance gain since we don't need to create a
subprocess, but it also allows us to use the ref transactions api in the
future.
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | builtin/stash.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index 5897febfbe..3e2f478b76 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)); |
