Skip to content

Commit 3c386aa

Browse files
drafnelgitster
authored andcommitted
reflog-delete: parse standard reflog options
Add support for some standard reflog options such as --dry-run and --verbose to the reflog delete subcommand. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 50f3ac2 commit 3c386aa

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

builtin-reflog.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
static const char reflog_expire_usage[] =
1616
"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
17+
static const char reflog_delete_usage[] =
18+
"git-reflog delete [--verbose] [--dry-run] <refs>...";
1719

1820
static unsigned long default_reflog_expire;
1921
static unsigned long default_reflog_expire_unreachable;
@@ -425,12 +427,28 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
425427
struct cmd_reflog_expire_cb cb;
426428
int i, status = 0;
427429

428-
if (argc < 2)
429-
return error("Nothing to delete?");
430-
431430
memset(&cb, 0, sizeof(cb));
432431

433432
for (i = 1; i < argc; i++) {
433+
const char *arg = argv[i];
434+
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
435+
cb.dry_run = 1;
436+
else if (!strcmp(arg, "--verbose"))
437+
cb.verbose = 1;
438+
else if (!strcmp(arg, "--")) {
439+
i++;
440+
break;
441+
}
442+
else if (arg[0] == '-')
443+
usage(reflog_delete_usage);
444+
else
445+
break;
446+
}
447+
448+
if (argc - i < 1)
449+
return error("Nothing to delete?");
450+
451+
for ( ; i < argc; i++) {
434452
const char *spec = strstr(argv[i], "@{");
435453
unsigned char sha1[20];
436454
char *ep, *ref;

0 commit comments

Comments
 (0)