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

[PATCH] Fix race condition in t9119-git-svn-info.sh

From
David D. Kilzer <ddkilzer@kilzer.net>
Date
Dec 31, 2007, 20:07 UTC
Message-ID
<1199131665-1633-1-git-send-email-ddkilzer@kilzer.net>
In-Reply-To
<377939.62541.qm@web52402.mail.re2.yahoo.com>

Changed the ptouch bash function to use the "Text Last Updated" date reported by 'svn info' when changing the modified time (mtime) of the file/symlink/directory in the git working directory. Previously it used the mtime of the item in the svn working directory, which caused the race condition.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
---

Ran a "burn-in" test by applying the "make test" patch in <http://marc.info/?l=git&m=119452148511531&w=2> for over an hour with no test failures:

$ set -e $ while /usr/bin/true; do (make t/t9119-git-svn-info.sh); done

Also ran "make -C t full-svn-test" to verify the fix.
 t/t9119-git-svn-info.sh |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index cc61911..6d9bec9 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -5,17 +5,22 @@
 test_description='git-svn info'
 
 . ./lib-git-svn.sh
-say 'skipping svn-info test (has a race undiagnosed yet)'
-test_done
 
 ptouch() {
 	perl -w -e '
 		use strict;
+		use POSIX qw(mktime);
 		die "ptouch requires exactly 2 arguments" if @ARGV != 2;
-		die "$ARGV[0] does not exist" if ! -e $ARGV[0];
-		my @s = stat $ARGV[0];
-		utime $s[8], $s[9], $ARGV[1];
-	' "$1" "$2"
+		my $text_last_updated = shift @ARGV;
+		my $git_file = shift @ARGV;
+		die "\"$git_file\" does not exist" if ! -e $git_file;
+		if ($text_last_updated
+		    =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
+			my $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);
+			my $atime = $mtime;
+			utime $atime, $mtime, $git_file;
+		}
+	' "`svn info $1 | grep '^Text Last Updated:'`" "$2"
 }
 
 test_expect_success 'setup repository and import' "
@@ -111,7 +116,7 @@ test_expect_success 'info added-file' "
 		git add added-file &&
 	cd .. &&
 	cp gitwc/added-file svnwc/added-file &&
-	ptouch gitwc/added-file svnwc/added-file &&
+	ptouch svnwc/added-file gitwc/added-file &&
 	cd svnwc &&
 		svn add added-file > /dev/null &&
 	cd .. &&
@@ -127,7 +132,7 @@ test_expect_success 'info --url added-file' '
 
 test_expect_success 'info added-directory' "
 	mkdir gitwc/added-directory svnwc/added-directory &&
-	ptouch gitwc/added-directory svnwc/added-directory &&
+	ptouch svnwc/added-directory gitwc/added-directory &&
 	touch gitwc/added-directory/.placeholder &&
 	cd svnwc &&
 		svn add added-directory > /dev/null &&
@@ -156,7 +161,7 @@ test_expect_success 'info added-symlink-file' "
 		ln -s added-file added-symlink-file &&
 		svn add added-symlink-file > /dev/null &&
 	cd .. &&
-	ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
+	ptouch svnwc/added-symlink-file gitwc/added-symlink-file &&
 	(cd svnwc; svn info added-symlink-file) \
 		> expected.info-added-symlink-file &&
 	(cd gitwc; git-svn info added-symlink-file) \
@@ -179,7 +184,7 @@ test_expect_success 'info added-symlink-directory' "
 		ln -s added-directory added-symlink-directory &&
 		svn add added-symlink-directory > /dev/null &&
 	cd .. &&
-	ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
+	ptouch svnwc/added-symlink-directory gitwc/added-symlink-directory &&
 	(cd svnwc; svn info added-symlink-directory) \
 		> expected.info-added-symlink-directory &&
 	(cd gitwc; git-svn info added-symlink-directory) \
@@ -290,7 +295,7 @@ test_expect_success 'info --url symlink-directory (deleted)' '
 test_expect_success 'info unknown-file' "
 	echo two > gitwc/unknown-file &&
 	cp gitwc/unknown-file svnwc/unknown-file &&
-	ptouch gitwc/unknown-file svnwc/unknown-file &&
+	ptouch svnwc/unknown-file gitwc/unknown-file &&
 	(cd svnwc; svn info unknown-file) 2> expected.info-unknown-file &&
 	(cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file &&
 	git-diff expected.info-unknown-file actual.info-unknown-file
@@ -304,7 +309,7 @@ test_expect_success 'info --url unknown-file' '
 
 test_expect_success 'info unknown-directory' "
 	mkdir gitwc/unknown-directory svnwc/unknown-directory &&
-	ptouch gitwc/unknown-directory svnwc/unknown-directory &&
+	ptouch svnwc/unknown-directory gitwc/unknown-directory &&
 	touch gitwc/unknown-directory/.placeholder &&
 	(cd svnwc; svn info unknown-directory) \
 		2> expected.info-unknown-directory &&
@@ -327,7 +332,7 @@ test_expect_success 'info unknown-symlink-file' "
 	cd svnwc &&
 		ln -s unknown-file unknown-symlink-file &&
 	cd .. &&
-	ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
+	ptouch svnwc/unknown-symlink-file gitwc/unknown-symlink-file &&
 	(cd svnwc; svn info unknown-symlink-file) \
 		2> expected.info-unknown-symlink-file &&
 	(cd gitwc; git-svn info unknown-symlink-file) \
@@ -350,8 +355,8 @@ test_expect_success 'info unknown-symlink-directory' "
 	cd svnwc &&
 		ln -s unknown-directory unknown-symlink-directory &&
 	cd .. &&
-	ptouch gitwc/unknown-symlink-directory \
-	       svnwc/unknown-symlink-directory &&
+	ptouch svnwc/unknown-symlink-directory \
+	       gitwc/unknown-symlink-directory &&
 	(cd svnwc; svn info unknown-symlink-directory) \
 		2> expected.info-unknown-symlink-directory &&
 	(cd gitwc; git-svn info unknown-symlink-directory) \
-- 
1.5.3.7
Previous: David D. KilzerNext: Junio C Hamano
Message 40 of 72 in “What's in git/spearce.git (stable)”
  1. Shawn O. PearceOct 22, 2007
  2. What's in git.git (stable)Junio C Hamano, Nov 1, 2007
  3. What's in git.git (stable)Junio C Hamano, Nov 4, 2007
  4. What's in git.git (stable)Junio C Hamano, Nov 8, 2007
  5. Pierre HabouzitNov 8, 2007
  6. What's in git.git (stable)Junio C Hamano, Nov 12, 2007
  7. What's in git.git (stable)Junio C Hamano, Nov 15, 2007
  8. What's in git.git (stable)Junio C Hamano, Nov 17, 2007
  9. What's in git.git (stable)Junio C Hamano, Nov 25, 2007
  10. What's in git.git (stable)Junio C Hamano, Dec 1, 2007
  11. What's in git.git (stable)Junio C Hamano, Dec 4, 2007
  12. What's in git.git (stable)Junio C Hamano, Dec 5, 2007
  13. What's in git.git (stable)Junio C Hamano, Dec 7, 2007
  14. What's in git.git (stable)Junio C Hamano, Dec 9, 2007
  15. v1.5.4 plansJunio C Hamano, Dec 10, 2007
  16. Jeff KingDec 10, 2007
  17. Junio C HamanoDec 11, 2007
  18. Junio C HamanoDec 11, 2007
  19. Jeff KingDec 11, 2007
  20. Junio C HamanoDec 11, 2007
  21. Jeff KingDec 11, 2007
  22. Junio C HamanoDec 11, 2007
  23. Jeff KingDec 11, 2007
  24. Jeff KingDec 11, 2007
  25. Jeff KingDec 11, 2007
  26. 2/2 git-svn: get color config from --get-colorboolJeff King, Dec 11, 2007
  27. Eric WongDec 12, 2007
  28. Jeff KingDec 11, 2007
  29. Andreas EricssonDec 11, 2007
  30. Jeff KingDec 11, 2007
  31. Nicolas PitreDec 11, 2007
  32. Johannes SchindelinDec 11, 2007
  33. Nicolas PitreDec 11, 2007
  34. Kristian HøgsbergDec 11, 2007
  35. Junio C HamanoDec 11, 2007
  36. Eric WongDec 12, 2007
  37. Junio C HamanoDec 12, 2007
  38. David D. KilzerDec 12, 2007
  39. David D. KilzerDec 31, 2007
  40. Fix race condition in t9119-git-svn-info.shDavid D. Kilzer, Dec 31, 2007
  41. Junio C HamanoDec 31, 2007
  42. Remove duplication in t9119-git-svn-info.shDavid D. Kilzer, Dec 31, 2007
  43. Eric WongJan 2, 2008
  44. David D. KilzerJan 2, 2008
  45. Junio C HamanoJan 2, 2008
  46. Junio C HamanoJan 2, 2008
  47. What's in git.git (stable frozen)Junio C Hamano, Dec 13, 2007
  48. git-commit: squelch needless message during an empty mergeJunio C Hamano, Dec 13, 2007
  49. Jeff KingDec 13, 2007
  50. Johannes SixtDec 13, 2007
  51. What's in git.git (stable frozen)Junio C Hamano, Dec 17, 2007
  52. What's in git.git (stable frozen)Junio C Hamano, Dec 23, 2007
  53. What's in git.git (stable frozen)Junio C Hamano, Jan 5, 2008
  54. Dan McGeeJan 5, 2008
  55. Junio C HamanoJan 6, 2008
  56. Junio C HamanoJan 6, 2008
  57. Dan McGeeJan 6, 2008
  58. Junio C HamanoJan 6, 2008
  59. Jeff KingJan 6, 2008
  60. Jeff KingJan 6, 2008
  61. Junio C HamanoJan 6, 2008
  62. Jeff KingJan 6, 2008
  63. Junio C HamanoJan 6, 2008
  64. Jeff KingJan 6, 2008
  65. Junio C HamanoJan 6, 2008
  66. Jeff KingJan 7, 2008
  67. Junio C HamanoJan 7, 2008
  68. Paul MackerrasJan 7, 2008
  69. Christian StimmingJan 7, 2008
  70. Junio C HamanoJan 7, 2008
  71. Steffen ProhaskaDec 17, 2007
  72. Junio C HamanoJan 5, 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.