summaryrefslogtreecommitdiff
path: root/builtin-reflog.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-02-22 15:08:59 -0600
committerJunio C Hamano <gitster@pobox.com>2008-02-22 22:57:34 -0800
commit3c386aa3380b698396d522f1132343ced482ff42 (patch)
tree9f6e5f4707edcb7228ed26bb8250c6c62deeba6b /builtin-reflog.c
parent50f3ac29cbadbf7e0ff099b493b00cfa4129e1e0 (diff)
downloadgit-3c386aa3380b698396d522f1132343ced482ff42.tar.gz
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>
Diffstat (limited to 'builtin-reflog.c')
-rw-r--r--builtin-reflog.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/builtin-reflog.c b/builtin-reflog.c
index 8af75bc3e1..77f70a62ab 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -14,6 +14,8 @@
static const char reflog_expire_usage[] =
"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+static const char reflog_delete_usage[] =
+"git-reflog delete [--verbose] [--dry-run] <refs>...";
static unsigned long default_reflog_expire;
static unsigned long default_reflog_expire_unreachable;
@@ -425,12 +427,28 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
struct cmd_reflog_expire_cb cb;
int i, status = 0;
- if (argc < 2)
- return error("Nothing to delete?");
-
memset(&cb, 0, sizeof(cb));
for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+ if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
+ cb.dry_run = 1;
+ else if (!strcmp(arg, "--verbose"))
+ cb.verbose = 1;
+ else if (!strcmp(arg, "--")) {
+ i++;
+ break;
+ }
+ else if (arg[0] == '-')
+ usage(reflog_delete_usage);
+ else
+ break;
+ }
+
+ if (argc - i < 1)
+ return error("Nothing to delete?");
+
+ for ( ; i < argc; i++) {
const char *spec = strstr(argv[i], "@{");
unsigned char sha1[20];
char *ep, *ref;