diff mbox series

[11/19] rev-parseopt: convert --reflog

Message ID 20190508111249.15262-12-pclouds@gmail.com (mailing list archive)
State New, archived
Headers show
Series Convert revision.c to parseopt part 1/4 | expand

Commit Message

Duy Nguyen May 8, 2019, 11:12 a.m. UTC
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 revision.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/revision.c b/revision.c
index d34e17984d..6efa9bee1e 100644
--- a/revision.c
+++ b/revision.c
@@ -2452,6 +2452,18 @@  static int rev_opt_glob(const struct option *opt,
 	return 0;
 }
 
+static int rev_opt_reflog(const struct option *opt,
+			  const char *arg, int unset)
+{
+	struct rev_info *revs  = opt->value;
+	int flags = *revs->pseudo_flags;
+
+	BUG_ON_OPT_NEG(unset);
+	BUG_ON_OPT_ARG(arg);
+	add_reflogs_to_pending(revs, flags);
+	return 0;
+}
+
 static int rev_opt_remotes(const struct option *opt,
 			   const char *arg, int unset)
 {
@@ -2528,6 +2540,9 @@  static void make_pseudo_options(struct rev_info *revs)
 		OPT_REV(0, "exclude", N_("<pattern>"),
 			N_("exclude refs matching glob pattern"),
 			rev_opt_exclude),
+		OPT_REV_NOARG(0, "reflog",
+			      N_("include all refs from reflog"),
+			      rev_opt_reflog),
 		OPT_END()
 	};
 	ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options));
@@ -2567,9 +2582,7 @@  static int handle_revision_pseudo_opt(const char *submodule,
 	if (argc)
 		return argc;
 
-	if (!strcmp(arg, "--reflog")) {
-		add_reflogs_to_pending(revs, *flags);
-	} else if (!strcmp(arg, "--indexed-objects")) {
+	if (!strcmp(arg, "--indexed-objects")) {
 		add_index_objects_to_pending(revs, *flags);
 	} else if (!strcmp(arg, "--not")) {
 		*flags ^= UNINTERESTING | BOTTOM;