Re: [PATCH] archive: add --mtime
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 18, 2023, 17:25 UTC
- Message-ID
- <xmqqilfykhsf.fsf@gitster.g>
- In-Reply-To
- <91a73f5d-ca3e-6cb0-4ba3-38d703074ee6@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 18 quoted lines
> +--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.