Subject: Re: [PATCH] archive: add --mtime

From: Junio C Hamano <[email-masked]>
Date: Sat, 18 Feb 2023 09:25:04 -0800

René Scharfe <[email-masked]> writes:

> +--mtime=<time>::
> +	Set modification time of archive entries.  Without this option
> +	the committer time is used if `<tree-ish>` is a commit or tag,
> +	and the current time if it is a tree.
> +
>  <extra>::
>  	This can be any options that the archiver backend understands.
>  	See next section.
> diff --git a/archive.c b/archive.c
> index 81ff76fce9..122860b39d 100644
> --- a/archive.c
> +++ b/archive.c
> @@ -472,6 +472,8 @@ static void parse_treeish_arg(const char **argv,
>  		commit_oid = NULL;
>  		archive_time = time(NULL);
>  	}
> +	if (ar_args->mtime_option)
> +		archive_time = approxidate(ar_args->mtime_option);

This is the solution with least damage, letting the existing code to
set archive_time and then discard the result and overwrite with the
command line option.

I wonder if we want to use approxidate_careful() to deal with bogus
input?  The code is perfectly serviceable without it (users who feed
bogus input deserve what they get), but some folks might prefer to
be "nicer" than necessary ;-)

Other than that, looks very good.  Thanks.