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

Re: Git should preserve modification times at least on request

From
Theodore Ts'o <tytso@mit.edu>
Date
Feb 20, 2018, 01:22 UTC
Message-ID
<20180220012219.GA9791@thunk.org>
In-Reply-To
<20180219220819.GA10466@helen.PLASMA.Xg8.DE>
On Mon, Feb 19, 2018 at 11:08:19PM +0100, Peter Backes wrote:
> Is thetre some existing code that could be used? I think I read 
> somewhere that git once did preserve mtimes, but that this code was 
> removed because of the build tool issues. Perhaps that code could 
> simply be put back in, and surrounded by conditions.

I don't believe that was ever true, because the mod times is simply not *stored* anywhere.

You might want to consider trying to implement it as hook scripts first, and see how well/poorly it works for you. I do have a use case, which is to maintain the timestamps for guilt (a quilt-like patch management system which uses git). At the moment I just use a manual script, save-timestamps, which looks like this:

#!/bin/sh stat -c "touch -d @%Y %n" * | sort -k 3 | grep -v "~$" | sort -k3 > timestamps

and then I just include the timestamps file in thhe commit. When I unpack the file elsewhere, I just run the command ". timestamps", or if I am manually editing a single file, I might do:

	grep file-name-of-patch timestamps | sht

This works because the timestamps file has lines which look like this:

touch -d @1519007593 jbd2-clarify-recovery-checksum-error-msg

I've been too lazy to automate this using a "pre-commit" and "post-checkout" hook, but it *really* wouldn't be that hard. Right now it also only works for files in the top-level of the repo, which is all I have in my guilt patch repo. Making this work in a multiple-directory environment is also left as an exercise to the reader. :-)

Cheers,
						- Ted

P.S. Also left to the reader is making it work on legacy OS's like Windows. :-)

Previous: Peter BackesNext: Johannes Schindelin
Message 4 of 28 in “Git should preserve modification times at least on request”
  1. Peter BackesFeb 19, 2018
  2. Johannes SchindelinFeb 19, 2018
  3. Peter BackesFeb 19, 2018
  4. Theodore Ts'oFeb 20, 2018
  5. Johannes SchindelinFeb 20, 2018
  6. Peter BackesFeb 20, 2018
  7. Peter BackesFeb 20, 2018
  8. Johannes SchindelinFeb 20, 2018
  9. Peter BackesFeb 20, 2018
  10. Phillip WoodFeb 21, 2018
  11. Randall S. BeckerFeb 19, 2018
  12. Hilco WijbengaFeb 19, 2018
  13. Hilco WijbengaFeb 20, 2018
  14. Jeff KingFeb 20, 2018
  15. Peter BackesFeb 20, 2018
  16. Jacob KellerFeb 21, 2018
  17. Junio C HamanoFeb 20, 2018
  18. Derek FawcusFeb 21, 2018
  19. Ævar Arnfjörð BjarmasonFeb 21, 2018
  20. Peter BackesFeb 21, 2018
  21. Ævar Arnfjörð BjarmasonFeb 21, 2018
  22. Peter BackesFeb 21, 2018
  23. Randall S. BeckerFeb 21, 2018
  24. 'Peter Backes'Feb 22, 2018
  25. Andreas KreyFeb 26, 2018
  26. 'Peter Backes'Feb 26, 2018
  27. Derek FawcusFeb 22, 2018
  28. Konstantin KhomoutovFeb 23, 2018

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.