[PATCH v3 0/3] Add some more options to the pretty-formats
- From
Eli Schwartz <eschwartz@archlinux.org>
- Date
- Oct 29, 2021, 18:45 UTC
- Message-ID
- <20211029184512.1568017-1-eschwartz@archlinux.org>
- In-Reply-To
- <20211026013452.1372122-1-eschwartz@archlinux.org>
This revision only contains style nits in response to review comments. See below.
Eli Schwartz (3): pretty.c: rework describe options parsing for better extensibility pretty: add tag option to %(describe) pretty: add abbrev option to %(describe)
Documentation/pretty-formats.txt | 16 +++++++--- pretty.c | 54 ++++++++++++++++++++++++++------ t/t4205-log-pretty-formats.sh | 16 ++++++++++ 3 files changed, 71 insertions(+), 15 deletions(-)
Range-diff against v2:
1: 1cf0d82b91 ! 1: 55a20468d3 pretty.c: rework describe options parsing for better extensibility
@@ pretty.c: int format_set_trailers_options(struct process_trailer_options *opts,
- &argval, &arglen)) {
- matched = options[i];
+ for (i = 0; !found && i < ARRAY_SIZE(option); i++) {
-+ switch(option[i].type) {
++ switch (option[i].type) {
+ case OPT_STRING:
+ if (match_placeholder_arg_value(arg, option[i].name, &arg,
-+ &argval, &arglen) && arglen) {
++ &argval, &arglen)) {
+ if (!arglen)
+ return 0;
+ strvec_pushf(args, "--%s=%.*s", option[i].name, (int)arglen, argval);
2: cb6af9bc14 ! 2: c34c8a4f7f pretty: add tag option to %(describe)
@@ pretty.c: static size_t parse_describe_args(const char *start, struct strvec *ar
int i;
for (i = 0; !found && i < ARRAY_SIZE(option); i++) {
- switch(option[i].type) {
+ switch (option[i].type) {
+ case OPT_BOOL:
-+ if(match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
-+ if (optval) {
++ if (match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
++ if (optval)
+ strvec_pushf(args, "--%s", option[i].name);
-+ } else {
++ else
+ strvec_pushf(args, "--no-%s", option[i].name);
-+ }
+ found = 1;
+ }
+ break;
case OPT_STRING:
if (match_placeholder_arg_value(arg, option[i].name, &arg,
- &argval, &arglen) && arglen) {
+ &argval, &arglen)) {
## t/t4205-log-pretty-formats.sh ##
@@ t/t4205-log-pretty-formats.sh: test_expect_success '%(describe:exclude=...) vs git describe --exclude ...' '
3: 08ade18b35 ! 3: b751aaf3c6 pretty: add abbrev option to %(describe)
@@ pretty.c: static size_t parse_describe_args(const char *start, struct strvec *ar
break;
+ case OPT_INTEGER:
+ if (match_placeholder_arg_value(arg, option[i].name, &arg,
-+ &argval, &arglen) && arglen) {
++ &argval, &arglen)) {
++ char *endptr;
+ if (!arglen)
+ return 0;
-+ char* endptr;
+ strtol(argval, &endptr, 10);
+ if (endptr - argval != arglen)
+ return 0;
@@ pretty.c: static size_t parse_describe_args(const char *start, struct strvec *ar
+ break;
case OPT_STRING:
if (match_placeholder_arg_value(arg, option[i].name, &arg,
- &argval, &arglen) && arglen) {
+ &argval, &arglen)) {
## t/t4205-log-pretty-formats.sh ##
@@ t/t4205-log-pretty-formats.sh: test_expect_success '%(describe:tags) vs git describe --tags' '-- 2.33.1