Skip to content

Commit 758b4d2

Browse files
john-caigitster
authored andcommitted
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 <[email protected]> Signed-off-by: John Cai <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d3d226 commit 758b4d2

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

builtin/stash.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "diffcore.h"
1818
#include "exec-cmd.h"
1919
#include "entry.h"
20+
#include "reflog.h"
2021

2122
#define INCLUDE_ALL_FILES 2
2223

@@ -634,20 +635,9 @@ static int reflog_is_empty(const char *refname)
634635

635636
static int do_drop_stash(struct stash_info *info, int quiet)
636637
{
637-
int ret;
638-
struct child_process cp_reflog = CHILD_PROCESS_INIT;
639-
640-
/*
641-
* reflog does not provide a simple function for deleting refs. One will
642-
* need to be added to avoid implementing too much reflog code here
643-
*/
644-
645-
cp_reflog.git_cmd = 1;
646-
strvec_pushl(&cp_reflog.args, "reflog", "delete", "--updateref",
647-
"--rewrite", NULL);
648-
strvec_push(&cp_reflog.args, info->revision.buf);
649-
ret = run_command(&cp_reflog);
650-
if (!ret) {
638+
if (!reflog_delete(info->revision.buf,
639+
EXPIRE_REFLOGS_REWRITE | EXPIRE_REFLOGS_UPDATE_REF,
640+
0)) {
651641
if (!quiet)
652642
printf_ln(_("Dropped %s (%s)"), info->revision.buf,
653643
oid_to_hex(&info->w_commit));

0 commit comments

Comments
 (0)