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

Re: preserving mtime

From
EWErik Warendorph <erik@warendorph.org>
Date
Nov 16, 2007, 12:09 UTC
Message-ID
<20071116120929.GA28144@localhost.localdomain>
In-Reply-To
<473D63F9.4010201@inrim.it>
* Fabrizio Pollastri <f.pollastri@inrim.it> [2007-11-16 10:33:45 +0100]:
>
> is it possible to tell git to preserve the file modification time in a 
> checked out copy? It is useful when managing web files, where mtime is 
> tested by spiders for download decisions.

You may find the script "git-set-file-times" in the GitWiki useful:

  ExampleScripts - GitWiki
  Setting the timestamps of the files to the commit timestamp
  of the commit which last touched them
    <http://git.or.cz/gitwiki/ExampleScripts#head-a57deb2b4ab1e2de80ab5fd3c681a6055a9d3247>

You should of course pay attention to advice about (and against) doing stuff like this, both in the description of that script and in other postings on this list. But as you are using Git to manage web files and you (probably) don't care about build systems such as "make", you should be pretty safe.

About the script: I think it originally was made by Eric Wong (= normalperson) who is also on this list. I have just made a tiny, tiny modification to it (adding " or s/\0$//" to the elsif test).

I've also thought about adding a --prefix option to the script. This would enable it to be used together with git-archive, leaving the working directory alone and affecting the files in the directory where the archive is extracted instead. In this way, you would distinguish between your working directory and your "live" directory, and the command sequence

  git archive --prefix=foo/ HEAD | (cd /var/www/ && tar xf -)
  git-set-file-times --prefix=/var/www/foo/

would be part of the build system, publishing your working directory to your "live" directory (in this case /var/www/foo/).

-- 
Erik Warendorph <erik@warendorph.org>
Previous: Junio C Hamano
Message 14 of 14 in “preserving mtime”
  1. Fabrizio PollastriNov 16, 2007
  2. Andreas EricssonNov 16, 2007
  3. Wayne DavisonNov 17, 2007
  4. Mike HommeyNov 18, 2007
  5. Martin LanghoffNov 18, 2007
  6. David BrownNov 18, 2007
  7. Martin LanghoffNov 18, 2007
  8. David BrownNov 18, 2007
  9. Jan HudecNov 18, 2007
  10. Robin RosenbergNov 18, 2007
  11. Johannes SchindelinNov 19, 2007
  12. Jakub NarebskiNov 16, 2007
  13. Junio C HamanoNov 16, 2007
  14. Erik WarendorphNov 16, 2007

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.