Web lists-archives.com

[PATCH 10/19] rev-parseopt: convert --exclude




Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 revision.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/revision.c b/revision.c
index 013b8ec19f..d34e17984d 100644
--- a/revision.c
+++ b/revision.c
@@ -2428,6 +2428,16 @@ static int rev_opt_branches(const struct option *opt,
 	return 0;
 }
 
+static int rev_opt_exclude(const struct option *opt,
+			   const char *arg, int unset)
+{
+	struct rev_info	*revs  = opt->value;
+
+	BUG_ON_OPT_NEG(unset);
+	add_ref_exclusion(&revs->ref_excludes, arg);
+	return 0;
+}
+
 static int rev_opt_glob(const struct option *opt,
 			const char *arg, int unset)
 {
@@ -2515,6 +2525,9 @@ static void make_pseudo_options(struct rev_info *revs)
 		OPT_REV(0, "glob", N_("<pattern>"),
 			N_("include all refs matching shell glob"),
 			rev_opt_glob),
+		OPT_REV(0, "exclude", N_("<pattern>"),
+			N_("exclude refs matching glob pattern"),
+			rev_opt_exclude),
 		OPT_END()
 	};
 	ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options));
@@ -2528,7 +2541,6 @@ static int handle_revision_pseudo_opt(const char *submodule,
 	const char *arg = argv[0];
 	const char *optarg;
 	struct ref_store *refs;
-	int argcount;
 
 	if (submodule) {
 		/*
@@ -2555,10 +2567,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
 	if (argc)
 		return argc;
 
-	if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
-		add_ref_exclusion(&revs->ref_excludes, optarg);
-		return argcount;
-	} else if (!strcmp(arg, "--reflog")) {
+	if (!strcmp(arg, "--reflog")) {
 		add_reflogs_to_pending(revs, *flags);
 	} else if (!strcmp(arg, "--indexed-objects")) {
 		add_index_objects_to_pending(revs, *flags);
-- 
2.21.0.1141.gd54ac2cb17