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

Re: Feature request: Add --mtime option to git archive

From
Jeff King <peff@peff.net>
Date
Feb 16, 2023, 21:05 UTC
Message-ID
<Y+6akicTFG9n0eZy@coredump.intra.peff.net>
In-Reply-To
<Y+6G9n6cWRT9EKyl@google.com>
On Thu, Feb 16, 2023 at 12:41:42PM -0700, Raul E Rangel wrote:
> When generating a tarball with `git archive <tree>`, `git archive` will
> use the current time as the mtime. This results in a non-hermetic
> tarball. Could we should add a --mtime option that allows passing in
> the time? 

That seems like a very reasonable feature to have. Just to sketch out the implementation, in case anybody wants to work on it:

  - options are read first in cmd_archive(), but it passes unknown ones
    on to write_archive(), which is where we parse the interesting ones.
  - that relies on parse_archive_args() in archive.c. So we'd want a new
    option in opts[] there, and to write the value into a new field in
    the archiver_args struct.
  - the time is filled in via parse_treeish_arg(), where we use
    time(NULL) if there's no commit. And there we'd just use the value
    from archiver_args.
    If there is a commit and they've specified --mtime, what should
    happen? Quietly ignore it? Override the commit's timestamp? Complain
    and bail?
  - I didn't look at how this might interact with "git archive
    --remote". I think it might just all work, as we just ship the
    options to the other side, which parses them itself using the same
    code.
-Peff
Previous: Raul E RangelNext: Junio C Hamano
Message 2 of 16 in “Feature request: Add --mtime option to git archive”
  1. Raul E RangelFeb 16, 2023
  2. Jeff KingFeb 16, 2023
  3. Junio C HamanoFeb 16, 2023
  4. Jeff KingFeb 17, 2023
  5. Junio C HamanoFeb 17, 2023
  6. Raul RangelFeb 17, 2023
  7. René ScharfeFeb 17, 2023
  8. Jeff KingFeb 17, 2023
  9. demerphqFeb 18, 2023
  10. brian m. carlsonFeb 18, 2023
  11. archive: add --mtimeRené Scharfe, Feb 18, 2023
  12. Junio C HamanoFeb 18, 2023
  13. René ScharfeFeb 19, 2023
  14. Junio C HamanoFeb 21, 2023
  15. Jeff KingFeb 22, 2023
  16. Junio C HamanoFeb 22, 2023

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.