Re: [PATCH v3 3/4] archive-tar: write extended headers for far-future mtime
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 24, 2016, 19:06 UTC
- Message-ID
- <xmqqshw2flt8.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160623232112.GC3668@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> There's a slight bit of trickiness there. We may already be > ... > After writing the extended header, we munge the timestamp in > the ustar headers to the maximum-allowable size. This is > wrong, but it's the least-wrong thing we can provide to a > tar implementation that doesn't understand pax headers (it's > also what GNU tar does).
The above looks very sensible design, and its implementation is surprisingly compact. Very nicely done.
Show 27 quoted lines
> Helped-by: René Scharfe <l.s.r@web.de>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> archive-tar.c | 16 +++++++++++++---
> t/t5000-tar-tree.sh | 4 ++--
> 2 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/archive-tar.c b/archive-tar.c
> index 274bdfa..0bb164c 100644
> --- a/archive-tar.c
> +++ b/archive-tar.c
> @@ -317,7 +317,18 @@ static int write_global_extended_header(struct archiver_args *args)
> unsigned int mode;
> int err = 0;
>
> - strbuf_append_ext_header(&ext_header, "comment", sha1_to_hex(sha1), 40);
> + if (sha1)
> + strbuf_append_ext_header(&ext_header, "comment",
> + sha1_to_hex(sha1), 40);
> + if (args->time > 077777777777UL) {
> + strbuf_append_ext_header_uint(&ext_header, "mtime",
> + args->time);
> + args->time = 077777777777UL;
> + }
> +
> + if (!ext_header.len)
> + return 0;Another symbolic constant to explain this, e.g. TAR_TIME_LIMIT, may want to exist.
Thanks.