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

Re: timestamps not git-cloned

From
Thomas Rast <trast@student.ethz.ch>
Date
Nov 29, 2008, 10:16 UTC
Message-ID
<200811291117.01655.trast@student.ethz.ch>
In-Reply-To
<20081129092231.GA32630@cuci.nl>
Stephen R. van den Berg wrote:
Show 6 quoted lines
> Chris Frey wrote:
> >If this is the important bit, perhaps git-archive could be changed
> >to create tarballs with file timestamps based on their commit dates.
> 
> Based on the principle of least surprise, I'd consider this a rather good
> idea.

Unless I'm missing something, this would make git-archive rather more expensive than it is now: Tree objects do not record any timestamps, so figuring out the last commit that changed a file requires a full history walk in the worst case[*]. (This is another side-effect of not versioning files.) On the other hand, current git-archive's running time depends only on the size of the tree-ish given, including all subtrees and blobs.

My unscientific guesstimates on how much work this would be, in a random (old) linux-2.6 clone:

  $ git rev-parse HEAD
  e013e13bf605b9e6b702adffbe2853cfc60e7806
  $ time git ls-tree -r -t $(git rev-list HEAD~5000..HEAD) >/dev/null
  real    0m1.385s
  user    0m1.164s
  sys     0m0.220s
  $ git rev-list HEAD | wc -l
  117812

So reading (and dumping) all those trees and subtrees incurs a penalty on the order of 30 seconds. Compare to the current running time of git-archive:

  $ time git archive --format=tar HEAD >/dev/null
  real    0m2.790s
  user    0m2.684s
  sys     0m0.072s
Of course, the ratio will keep getting worse as history gets longer.
- Thomas

[*] I think to really have a "worst case" here, you need at least one file in every leaf directory that has not changed since the root commit, and another that changes in every commit to force the search to really read every subtree.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Stephen R. van den BergNext: jidanni@jidanni.org
Message 7 of 16 in “timestamps not git-cloned”
  1. jidanni@jidanni.orgNov 28, 2008
  2. dhruvaNov 28, 2008
  3. jidanni@jidanni.orgNov 28, 2008
  4. Daniel BarkalowNov 28, 2008
  5. Chris FreyNov 29, 2008
  6. Stephen R. van den BergNov 29, 2008
  7. Thomas RastNov 29, 2008
  8. jidanni@jidanni.orgNov 30, 2008
  9. Andreas EricssonDec 1, 2008
  10. Jakub NarebskiDec 1, 2008
  11. Sitaram ChamartyNov 30, 2008
  12. David BrownNov 28, 2008
  13. Peter KreftingNov 28, 2008
  14. Johannes SchindelinNov 28, 2008
  15. Robin RosenbergNov 28, 2008
  16. Johannes SchindelinNov 28, 2008

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.