diff mbox series

[13/19] rev-parseopt: convert --not

Message ID 20190508111249.15262-14-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 | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/revision.c b/revision.c
index 9cfa4dc151..b02cb4660b 100644
--- a/revision.c
+++ b/revision.c
@@ -2464,6 +2464,17 @@  static int rev_opt_glob(const struct option *opt,
 	return 0;
 }
 
+static int rev_opt_not(const struct option *opt,
+		       const char *arg, int unset)
+{
+	struct rev_info *revs  = opt->value;
+
+	BUG_ON_OPT_NEG(unset);
+	BUG_ON_OPT_ARG(arg);
+	*revs->pseudo_flags ^= UNINTERESTING | BOTTOM;
+	return 0;
+}
+
 static int rev_opt_reflog(const struct option *opt,
 			  const char *arg, int unset)
 {
@@ -2558,6 +2569,9 @@  static void make_pseudo_options(struct rev_info *revs)
 		OPT_REV_NOARG(0, "indexed-objects",
 			      N_("include all trees and blobs used by the index"),
 			      rev_opt_indexed_objects),
+		OPT_REV_NOARG(0, "not",
+			      N_("reverse the meaning of '^' for all following revisions"),
+			      rev_opt_not),
 		OPT_END()
 	};
 	ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options));
@@ -2597,9 +2611,7 @@  static int handle_revision_pseudo_opt(const char *submodule,
 	if (argc)
 		return argc;
 
-	if (!strcmp(arg, "--not")) {
-		*flags ^= UNINTERESTING | BOTTOM;
-	} else if (!strcmp(arg, "--no-walk")) {
+	if (!strcmp(arg, "--no-walk")) {
 		revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
 	} else if (skip_prefix(arg, "--no-walk=", &optarg)) {
 		/*