summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorLibravatar Eli Schwartz <eschwartz@archlinux.org>2021-10-31 13:15:09 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-11-01 10:34:34 -0700
commit1d517ceab98fd5c3c1a8fb6ef575b44c31ea7a9e (patch)
treef702131331c063c19d935107ffe69f55e51a142b /pretty.c
parentpretty.c: rework describe options parsing for better extensibility (diff)
downloadtgif-1d517ceab98fd5c3c1a8fb6ef575b44c31ea7a9e.tar.xz
pretty: add tag option to %(describe)
The %(describe) placeholder by default, like `git describe`, only supports annotated tags. However, some people do use lightweight tags for releases, and would like to describe those anyway. The command line tool has an option to support this. Teach the placeholder to support this as well. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/pretty.c b/pretty.c
index 6e945fdb18..52741fa0a9 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1219,9 +1219,11 @@ static size_t parse_describe_args(const char *start, struct strvec *args)
struct {
char *name;
enum {
+ DESCRIBE_ARG_BOOL,
DESCRIBE_ARG_STRING,
} type;
} option[] = {
+ { "tags", DESCRIBE_ARG_BOOL},
{ "exclude", DESCRIBE_ARG_STRING },
{ "match", DESCRIBE_ARG_STRING },
};
@@ -1231,10 +1233,20 @@ static size_t parse_describe_args(const char *start, struct strvec *args)
int found = 0;
const char *argval;
size_t arglen = 0;
+ int optval = 0;
int i;
for (i = 0; !found && i < ARRAY_SIZE(option); i++) {
switch (option[i].type) {
+ case DESCRIBE_ARG_BOOL:
+ if (match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
+ if (optval)
+ strvec_pushf(args, "--%s", option[i].name);
+ else
+ strvec_pushf(args, "--no-%s", option[i].name);
+ found = 1;
+ }
+ break;
case DESCRIBE_ARG_STRING:
if (match_placeholder_arg_value(arg, option[i].name, &arg,
&argval, &arglen)) {