git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] C: use skip-prefix to avoid hardcoded string length
Date: Thu, 30 Jan 2020 19:19:07 -0500	[thread overview]
Message-ID: <20200131001907.GD2394563@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqa764d9f1.fsf_-_@gitster-ct.c.googlers.com>

On Thu, Jan 30, 2020 at 11:35:46AM -0800, Junio C Hamano wrote:

>  * v2 uses a simpler conversion that has a side effect of changing
>    the error message from "git reflog expire" in a better way.

Thanks, this all looks good to me.

> diff --git a/builtin/reflog.c b/builtin/reflog.c
> index 4d3430900d..81dfd563c0 100644
> --- a/builtin/reflog.c
> +++ b/builtin/reflog.c
> @@ -560,15 +560,16 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
>  
>  	for (i = 1; i < argc; i++) {
>  		const char *arg = argv[i];
> +
>  		if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
>  			flags |= EXPIRE_REFLOGS_DRY_RUN;
> -		else if (starts_with(arg, "--expire=")) {
> -			if (parse_expiry_date(arg + 9, &cb.cmd.expire_total))
> +		else if (skip_prefix(arg, "--expire=", &arg)) {
> +			if (parse_expiry_date(arg, &cb.cmd.expire_total))
>  				die(_("'%s' is not a valid timestamp"), arg);
>  			explicit_expiry |= EXPIRE_TOTAL;
>  		}

I'm not sure if you meant to leave the blank-line addition, or if it was
a leftover from when there was a variable added there in v1. I think the
result is more readable, though, so I certainly don't mind it. ;)

-Peff

  reply	other threads:[~2020-01-31  0:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 22:21 [PATCH] C: use skip-prefix to avoid hardcoded string length Junio C Hamano
2020-01-27 23:20 ` Jeff King
2020-01-28  0:45   ` Junio C Hamano
2020-01-30 19:35     ` [PATCH v2] " Junio C Hamano
2020-01-31  0:19       ` Jeff King [this message]
2020-01-31 20:15       ` Andrei Rybak
2020-01-31 21:03         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200131001907.GD2394563@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).