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

Re: Git checkout preserve timestamp?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 5, 2007, 22:37 UTC
Message-ID
<Pine.LNX.4.64.0703051431130.3998@woody.linux-foundation.org>
In-Reply-To
<17900.39124.763603.695942@lisa.zopyra.com>
On Mon, 5 Mar 2007, Bill Lear wrote:
Show 5 quoted lines
>
> Maybe, maybe not.  Each argument I've seen doesn't convince me.  Sure,
> it may be MESSY.  It may be UGLY, and therefore undesirable, but I
> don't think any of the arguments have conclusively shown that it
> is WRONG or INFEASIBLE in any way.

I'm sorry. If you don't see how it's WRONG to seta datestamp back to something that will make a simple "make" *miscompile* your source tree, I don't know what defintiion of "wrong" you are talking about.

It's WRONG. 
It's STUPID.
And it's totally INFEASIBLE to implement.
Show 6 quoted lines
> Why should I care whether git knows this?  I never said it should.  As
> I said, if I have make products in separate, per-branch directories (a
> minor extension to my current make system), I don't see how this would
> be confusing in the least.  Git should only care if the content of the
> file in the index changes.  It shouldn't care in the least about my
> make products.

But Bill, the content in the index *does* change. It's that simple. It changes every time you check out another branch. And if it doesn't change, git already avoids changing mtime (because git already avoids changing the file).

Show 12 quoted lines
> Here's the flow.  Perhaps I'm fundamentally confused, and I'll be
> the first to admit that is true in plenty of ways:
> 
> I edit sourcefile.c, compile it, then commit it with
> N=timestamp(sourcefile.c) on master.  N is <
> timestamp(.master/sourcefile.o).  I then switch to branchX.  N is
> stored by git for master:sourcefile.c.  No stored timestamp are on
> this branch, so the file gets the timestamp it gets on checkout
> M=timestamp(sourcefile.c).  I compile the file again, all is well.  I
> move back to master branch.  Git stores M as branchX:sourcefile.c Git
> checks out the file, and stamps it with N.  I do a make.  No
> recompilation happens.

WHICH IS WRONG! You need to recompile, since the compile you did on the other branch DOES NOT MATCH in "sourcefile.c" any more.

And if sourcefile.c _does_ match in the two branches, then git *already* won't have changed it at all, so git already does the obvious optimization.

The thing is, "ccache" actually does this right. You could arguably integrate ccache with more git integration, and let ccache just use the SHA1's that git already caches and knows about. But the real issue is that what _you_ suggest is crazy. It doesn't work.

		Linus
Previous: Bill LearNext: Bill Lear
Message 23 of 51 in “Git checkout preserve timestamp?”
  1. Bill LearMar 1, 2007
  2. Alex RiesenMar 1, 2007
  3. Johannes SchindelinMar 1, 2007
  4. Linus TorvaldsMar 1, 2007
  5. Johannes SchindelinMar 1, 2007
  6. Karl HasselströmMar 2, 2007
  7. Bill LearMar 2, 2007
  8. Bart TrojanowskiMar 2, 2007
  9. Johannes SchindelinMar 2, 2007
  10. Karl HasselströmMar 2, 2007
  11. Johannes SchindelinMar 2, 2007
  12. Karl HasselströmMar 5, 2007
  13. Johannes SchindelinMar 5, 2007
  14. Karl HasselströmMar 5, 2007
  15. Bill LearMar 5, 2007
  16. Johannes SchindelinMar 5, 2007
  17. Bill LearMar 5, 2007
  18. Johannes SchindelinMar 5, 2007
  19. Bill LearMar 5, 2007
  20. Linus TorvaldsMar 5, 2007
  21. Matthieu MoyMar 5, 2007
  22. Bill LearMar 5, 2007
  23. Linus TorvaldsMar 5, 2007
  24. Bill LearMar 5, 2007
  25. Johannes SchindelinMar 5, 2007
  26. Bill LearMar 5, 2007
  27. Johannes SchindelinMar 5, 2007
  28. Michael PooleMar 6, 2007
  29. Johannes SchindelinMar 6, 2007
  30. Michael PooleMar 6, 2007
  31. Johannes SchindelinMar 6, 2007
  32. Junio C HamanoMar 6, 2007
  33. Sergio CallegariMar 6, 2007
  34. Jakub NarebskiMar 6, 2007
  35. Bill LearMar 6, 2007
  36. Johannes SchindelinMar 6, 2007
  37. Bill LearMar 6, 2007
  38. Martin LanghoffMar 6, 2007
  39. Theodore TsoMar 6, 2007
  40. Matthieu MoyMar 5, 2007
  41. Johannes SchindelinMar 5, 2007
  42. Bill LearMar 5, 2007
  43. Johannes SchindelinMar 5, 2007
  44. Bill LearMar 5, 2007
  45. Andy ParkinsMar 5, 2007
  46. Karl HasselströmMar 5, 2007
  47. Andy ParkinsMar 5, 2007
  48. Karl HasselströmMar 5, 2007
  49. Bill LearMar 5, 2007
  50. Andy ParkinsMar 5, 2007
  51. Bill LearMar 5, 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.