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

Re: [PATCH] Add a 1-second sleep to git-cvsexportcommit test

From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Date
Jul 24, 2007, 22:56 UTC
Message-ID
<200707250056.20880.robin.rosenberg.lists@dewire.com>
In-Reply-To
<alpine.LFD.0.999.0707241144490.3607@woody.linux-foundation.org>
tisdag 24 juli 2007 skrev Linus Torvalds:
Show 23 quoted lines
> 
> On Tue, 24 Jul 2007, Robin Rosenberg wrote:
> >
> > 27778 time(NULL)                        = 1185268822
> > 27778 gettimeofday({1185268822, 953340}, NULL) = 0
> > 
> > Here CVS sleeps. The amount varies between invocations since it
> > only sleeps enough for the seconds to wrap.
> > 
> > 27778 nanosleep({0, 46660000}, NULL)    = 0
> > 27778 time(NULL)                        = 1185268823
> 
> Btw, this is *really* dangerous and buggy.
> 
> The reason? The CPU real-time clock is very different from whatever clock 
> the filesystems may use.
> 
> Filesystems generally do not use the same clock as the CPU does. That's 
> obviously true for things like networked filesystems, but it's actually 
> true even for local filesystems (even on UP) because the CPU "realtime" 
> clock rather expensive and much too exact for them. It does all the fancy 
> NTP date correction etc, and it has all the complex code to actually make 
> sure you don't get any time jumps etc.

Having our mind enlightened, I propose this or nothing as a workaround. Since cvsexportcommit is really a CVS workaround we might work around some bugs in CVS itself while we're at it.

-- robin
From: Robin Rosenberg <robin.rosenberg@dewire.com>
Date: Wed, 25 Jul 2007 00:53:24 +0200
Subject: [PATCH] Sleep in git-cvsexportcommit

If git cvsexportcommit is executed fast enough in sequence, the CVS timestamps could end up being the same. CVS tries to fix this by sleeping until the CPU clock changes seconds. Unfortunately, the CPU clock and the file system clock are not necessarily the same, so the timestamps could be the same anyway. When that happens CVS may not recognize changed files and cvs will forget to commit some files.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 git-cvsexportcommit.perl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index d6ae99b..f6366be 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -277,6 +277,11 @@ if ($opt_c) {
 # clean up
 unlink(".cvsexportcommit.diff");
 
+# CVS version 1.11.x and 1.12.x sleeps the wrong way to ensure the timestamp 
+# used by CVS and the one set by subsequence file modifications are different.
+# If they are not different CVS will not detect changes.
+sleep(1);
+
 sub usage {
 	print STDERR <<END;
 Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [-f] [-m msgprefix] [ parent ] commit
-- 
1.5.2.3
Previous: Linus TorvaldsNext: Linus Torvalds
Message 18 of 21 in “Test #7 in t9200-git-cvsexportcommit fails”
  1. Jason SewallJul 22, 2007
  2. Alex RiesenJul 22, 2007
  3. Jason SewallJul 22, 2007
  4. Alex RiesenJul 22, 2007
  5. Junio C HamanoJul 22, 2007
  6. Add a 1-second sleep to git-cvsexportcommit testJason Sewall, Jul 23, 2007
  7. Junio C HamanoJul 23, 2007
  8. Simon 'corecode' SchubertJul 23, 2007
  9. Robin RosenbergJul 24, 2007
  10. Simon 'corecode' SchubertJul 24, 2007
  11. Robin RosenbergJul 24, 2007
  12. Simon 'corecode' SchubertJul 24, 2007
  13. Robin RosenbergJul 24, 2007
  14. Junio C HamanoJul 24, 2007
  15. Robin RosenbergJul 24, 2007
  16. Jason SewallJul 24, 2007
  17. Linus TorvaldsJul 24, 2007
  18. Robin RosenbergJul 24, 2007
  19. Linus TorvaldsJul 24, 2007
  20. Andy ParkinsJul 25, 2007
  21. Marius Storm-OlsenJul 25, 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.