git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Silly "git gc" UI issue.

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 20, 2018, 00:14 UTC
Message-ID
<xmqqlgdid99h.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180419103447.GA19591@ruderich.org>
Simon Ruderich <simon@ruderich.org> writes:
Show 10 quoted lines
> On Thu, Apr 19, 2018 at 10:52:47AM +0900, Junio C Hamano wrote:
>> It turns out that prune silently goes away given a bad expiry
>>
>>     $ git prune --expire=nyah ; echo $?
>>     129
>
> I noticed that git log --since/--after/--before/--until have a
> similar behavior and ignore date parsing errors in those options
> completely. Is this expected or should we warn the user with
> something like the following?

I do not have a strong opinion on this, because I would expect that "git log --since=nyah" to do whatever random things it may want to do.

But I suspect I am a minority, and if we were to change the established behaviour, I agree that erroring out using approxidate_careful() is the right direction to go in.

Thanks.
Show 43 quoted lines
> diff --git a/revision.c b/revision.c
> index 4e0e193e57..e5ba6c7dfc 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1794,19 +1794,31 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
>  		revs->max_age = atoi(optarg);
>  		return argcount;
>  	} else if ((argcount = parse_long_opt("since", argv, &optarg))) {
> -		revs->max_age = approxidate(optarg);
> +		int err = 0;
> +		revs->max_age = approxidate_careful(optarg, &err);
> +		if (err)
> +			return error("--since: invalid time '%s'", optarg);
>  		return argcount;
>  	} else if ((argcount = parse_long_opt("after", argv, &optarg))) {
> -		revs->max_age = approxidate(optarg);
> +		int err = 0;
> +		revs->max_age = approxidate_careful(optarg, &err);
> +		if (err)
> +			return error("--after: invalid time '%s'", optarg);
>  		return argcount;
>  	} else if ((argcount = parse_long_opt("min-age", argv, &optarg))) {
>  		revs->min_age = atoi(optarg);
>  		return argcount;
>  	} else if ((argcount = parse_long_opt("before", argv, &optarg))) {
> -		revs->min_age = approxidate(optarg);
> +		int err = 0;
> +		revs->min_age = approxidate_careful(optarg, &err);
> +		if (err)
> +			return error("--before: invalid time '%s'", optarg);
>  		return argcount;
>  	} else if ((argcount = parse_long_opt("until", argv, &optarg))) {
> -		revs->min_age = approxidate(optarg);
> +		int err = 0;
> +		revs->min_age = approxidate_careful(optarg, &err);
> +		if (err)
> +			return error("--until: invalid time '%s'");
>  		return argcount;
>  	} else if (!strcmp(arg, "--first-parent")) {
>  		revs->first_parent_only = 1;
>
> Regards
> Simon
Previous: Simon Ruderich
Message 14 of 14 in “Silly "git gc" UI issue.”
  1. Linus TorvaldsApr 19, 2018
  2. Junio C HamanoApr 19, 2018
  3. Junio C HamanoApr 19, 2018
  4. Junio C HamanoApr 19, 2018
  5. Linus TorvaldsApr 19, 2018
  6. Junio C HamanoApr 19, 2018
  7. Junio C HamanoApr 19, 2018
  8. Simon RuderichApr 20, 2018
  9. Junio C HamanoApr 21, 2018
  10. Christian CouderApr 21, 2018
  11. Junio C HamanoApr 23, 2018
  12. Linus TorvaldsApr 19, 2018
  13. Simon RuderichApr 19, 2018
  14. Junio C HamanoApr 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.