@matheusbsbs / matheus-bagliano / commits / 3c386aa338
Fork 0

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>

Brandon Casey committed Feb 22, 2008 at 15:08 UTC 3c386aa3380b698396d522f1132343ced482ff42
1 file changed +21 -3
builtin-reflog.c
+21 -3
@@ -14,6 +14,8 @@
14
15 static const char reflog_expire_usage[] =
16 "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>...";
19
20 static unsigned long default_reflog_expire;
21 static unsigned long default_reflog_expire_unreachable;
@@ -425,12 +427,28 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
427 struct cmd_reflog_expire_cb cb;
428 int i, status = 0;
429
428 - if (argc < 2)
429 - return error("Nothing to delete?");
430 -
430 memset(&cb, 0, sizeof(cb));
431
432 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++) {
452 const char *spec = strstr(argv[i], "@{");
453 unsigned char sha1[20];
454 char *ep, *ref;