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

Re: Git should preserve modification times at least on request

From
PBPeter Backes <rtc@helen.plasma.xg8.de>
Date
Feb 21, 2018, 23:12 UTC
Message-ID
<20180221231234.GA8509@helen.PLASMA.Xg8.DE>
In-Reply-To
<87a7w2ezeq.fsf@evledraar.gmail.com>
On Wed, Feb 21, 2018 at 11:44:13PM +0100, Ævar Arnfjörð Bjarmason wrote:
> If it were added as a first-level feature to git it would present a lot
> of UX confusion. E.g. you run "git add" and it'll be showing the mtime
> somehow, or you get a formatted patch over E-Mail and it doesn't only
> include the commit time but also times for individual files.

But that's pretty standard. patch format has timestamp fields for precisely this purpose:

% echo a > x % echo b > y % diff -u x y --- x 2018-02-21 23:56:29.574029523 +0100 +++ y 2018-02-21 23:56:31.430003389 +0100

@@ -1 +1 @@
-a
+b

At present, git simply leaves those fields blank...

> The VC systems that had this feature in the past were centralized, so
> they could (in theory anyway) ensure that timestamps were monotonically
> increasing. This won't be the case with git, we have plenty of timestamp
> drift in e.g. linux.git and other git repos.

I don't see where monotonicity would be an issue any more than it is 
for centralized version control systems.

Even in the centralized setting, monotonicity is not guaranteed, since 
you might have local timestamps deviating from the repository; you 
might have added a line, compiled, and removed it again later on, 
without running make again. Now if you checkout changes from the 
repository, and it sets the timestamp, that timestamp might be older 
than before the compile, and the file would not be rebuilt if you run 
make. So you cannot avoid those issues in centralized setttings either.

> So if these mtimes were used by default they'd interact badly with stuff
> like "make" in those cases, because you might check out a modified
> version with a timestamp in the past.

That's very clearly the case, and I have stressed in my initial email 
that I fully agree with the reasoning of the FAQ in this regard. It is, 
however, merely an argument against *restoring* the timestamps *by 
default*, to comply with the principle of least astonishment. It is, by 
itself, not an argument against *storing* the timestamps, let alone 
against restoring them *on request*.

For the initial checkout, it should not even be harmful to restore the 
timestamps by default.

> any case, I just wanted to point out a workaround (but then digressed
> into critiquing the idea above...).

Well, Johannes's proposed solution seems pretty reasonable and 
realistic to me.  Thanks to Phillip's hint about unquote_path() in 
Git.pm it seems I now have all the needed ingredients to implement this 
feature.

Best wishes
Peter
-- 
Peter Backes, rtc@helen.PLASMA.Xg8.DE
Previous: Ævar Arnfjörð BjarmasonNext: Randall S. Becker
Message 22 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.