Add a macro for using the '--contains' option in parse-options.h
also include an optional '--with' option macro which performs the
same action as '--contains'.
Make tag.c use this new macro
Mentored-by: Christian Couder
Mentored-by: Matthieu Moy
Signed-off-by: Karthik Nayak
---
builtin/tag.c | 14 ++
parse-options.h | 10 ++
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index eda76ba..e16668b 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -591,23 +591,13 @@ int cmd_tag(int argc, const char **argv, const char
*prefix)
OPT_GROUP(N_("Tag listing options")),
OPT_COLUMN(0, "column", &colopts, N_("show tag list in
columns")),
+ OPT_CONTAINS(&with_commit, N_("print only tags that contain the
commit")),
+ OPT_WITH(&with_commit, N_("print only tags that contain the
commit")),
{
OPTION_CALLBACK, 0, "sort", &tag_sort, N_("type"),
N_("sort tags"),
PARSE_OPT_NONEG, parse_opt_sort
},
{
- OPTION_CALLBACK, 0, "contains", &with_commit,
N_("commit"),
- N_("print only tags that contain the commit"),
- PARSE_OPT_LASTARG_DEFAULT,
- parse_opt_with_commit, (intptr_t)"HEAD",
- },
- {
- OPTION_CALLBACK, 0, "with", &with_commit, N_("commit"),
- N_("print only tags that contain the commit"),
- PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
- parse_opt_with_commit, (intptr_t)"HEAD",
- },
- {
OPTION_CALLBACK, 0, "points-at", &points_at,
N_("object"),
N_("print only tags of the object"), 0,
parse_opt_points_at
},
diff --git a/parse-options.h b/parse-options.h
index 7bcf0f3..d8389ad 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -254,5 +254,15 @@ extern int parse_opt_noop_cb(const struct option *, const
char *, int);
PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG, \
parse_opt_merge_filter, (intptr_t) "HEAD" \
}
+#define OPT_CONTAINS(filter, h) \
+ { OPTION_CALLBACK, 0, "contains", (filter), N_("commit"), (h), \
+ PARSE_OPT_LASTARG_DEFAULT, \
+ parse_opt_with_commit, (intptr_t) "HEAD" \
+ }
+#define OPT_WITH(filter, h) \
+ { OPTION_CALLBACK, 0, "with", (filter), N_("commit"), (h), \
+ PARSE_OPT_LASTARG_DEFAULT, \
+ parse_opt_with_commit, (intptr_t) "HEAD" \
+ }
#endif
--
2.4.2
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html