From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Raul E Rangel <rrangel@chromium.org>,
git@vger.kernel.org, Jeff King <peff@peff.net>,
demerphq <demerphq@gmail.com>
Subject: Re: [PATCH] archive: add --mtime
Date: Mon, 20 Feb 2023 21:37:18 -0800 [thread overview]
Message-ID: <xmqqlekrh94h.fsf@gitster.g> (raw)
In-Reply-To: 57b6643a-b9ff-3ea4-d60d-1a434d9ea75e@web.de
René Scharfe <l.s.r@web.de> writes:
>> 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 actually like Peff's solution more, because it's short and solves the
> specific problem of non-deterministic timestamps for tree archives.
Yes. That would be my preference as well. Without any UI to
educate users about.
> The --mtime option on the other hand mimics GNU tar, so it is more
> familiar and proven, though.
And that gives us the second best option ;-)
> It isn't all that careful, but you're right that we should do what we
> can. Like this on top? The message string is borrowed from commit's
> handling of --date.
Yeah, something like that, I would think.
Thanks.
> ---
> archive.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/archive.c b/archive.c
> index 122860b39d..871d80ee79 100644
> --- a/archive.c
> +++ b/archive.c
> @@ -438,6 +438,15 @@ static void parse_pathspec_arg(const char **pathspec,
> }
> }
>
> +static timestamp_t approxidate_or_die(const char *date_str)
> +{
> + int errors = 0;
> + timestamp_t date = approxidate_careful(date_str, &errors);
> + if (errors)
> + die(_("invalid date format: %s"), date_str);
> + return date;
> +}
> +
> static void parse_treeish_arg(const char **argv,
> struct archiver_args *ar_args, const char *prefix,
> int remote)
> @@ -473,7 +482,7 @@ static void parse_treeish_arg(const char **argv,
> archive_time = time(NULL);
> }
> if (ar_args->mtime_option)
> - archive_time = approxidate(ar_args->mtime_option);
> + archive_time = approxidate_or_die(ar_args->mtime_option);
>
> tree = parse_tree_indirect(&oid);
> if (!tree)
> --
> 2.39.2
next prev parent reply other threads:[~2023-02-21 5:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 19:41 Feature request: Add --mtime option to git archive Raul E Rangel
2023-02-16 21:05 ` Jeff King
2023-02-16 22:21 ` Junio C Hamano
2023-02-17 0:50 ` Jeff King
2023-02-17 2:04 ` Junio C Hamano
2023-02-17 15:43 ` Raul Rangel
2023-02-17 20:31 ` René Scharfe
2023-02-17 20:25 ` Jeff King
2023-02-18 3:04 ` demerphq
2023-02-18 17:08 ` brian m. carlson
2023-02-18 8:36 ` [PATCH] archive: add --mtime René Scharfe
2023-02-18 17:25 ` Junio C Hamano
2023-02-19 10:44 ` René Scharfe
2023-02-21 5:37 ` Junio C Hamano [this message]
2023-02-22 19:51 ` Jeff King
2023-02-22 23:23 ` 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=xmqqlekrh94h.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=demerphq@gmail.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=peff@peff.net \
--cc=rrangel@chromium.org \
/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).