{"thread":{"id":"14837","subject":"[PATCH 2/3] Fix race condition in t9119-git-svn-info.sh","startedAt":"2008-08-05T07:35:16Z","lastAt":"2008-08-05T07:35:18Z","messageCount":3,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"86264","messageId":"1217921718-25011-1-git-send-email-normalperson@yhbt.net","threadId":"14837","inReplyTo":null,"subject":"[PATCH 1/3] git-svn: properly set path for \"info\" command","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-08-05T07:35:16Z","receivedAt":"2008-08-05T07:35:16Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"canonicalize_path() was previously changed to better\nfit SVN 1.5, but it makes the \"info\" command not match\nsvn(1) in two places:\n\n  1) URL ended up with a trailing slash when run without an\n     argument.\n\n  2) \"Path: \" was displayed instead of \"Path: .\" when run\n     without an argument.\n\nWe will also handle odd cases where a user wants to\nget information on a file or directory named \"0\", too.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex cc35f50..df0ed90 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -796,8 +796,8 @@ sub cmd_commit_diff {\n }\n \n sub cmd_info {\n-\tmy $path = canonicalize_path(shift or \".\");\n-\tunless (scalar(@_) == 0) {\n+\tmy $path = canonicalize_path(defined($_[0]) ? $_[0] : \".\");\n+\tif (exists $_[1]) {\n \t\tdie \"Too many arguments specified\\n\";\n \t}\n \n@@ -813,6 +813,10 @@ sub cmd_info {\n \t\tdie \"Unable to determine upstream SVN information from \",\n \t\t    \"working tree history\\n\";\n \t}\n+\n+\t# canonicalize_path() will return \"\" to make libsvn 1.5.x happy,\n+\t$path = \".\" if $path eq \"\";\n+\n \tmy $full_url = $url . ($path eq \".\" ? \"\" : \"/$path\");\n \n \tif ($_url) {\n-- \n1.6.0.rc1.69.g797ea\n"},{"id":"86262","messageId":"1217921718-25011-2-git-send-email-normalperson@yhbt.net","threadId":"14837","inReplyTo":"1217921718-25011-1-git-send-email-normalperson@yhbt.net","subject":"[PATCH 2/3] Fix race condition in t9119-git-svn-info.sh","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-08-05T07:35:17Z","receivedAt":"2008-08-05T07:35:17Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"From: David D. Kilzer <ddkilzer@kilzer.net>\n\nChanged the ptouch bash function to use the \"Text Last Updated\"\ndate reported by 'svn info' when changing the modified time\n(mtime) of the file/symlink/directory in the git working\ndirectory.  Previously it used the mtime of the item in the\nsvn working directory, which caused the race condition.\n\n[ew: swapped argument order of ptouch() to minimize diff]\n\nFrom: David D. Kilzer <ddkilzer@kilzer.net>\n\nSigned-off-by: David D. Kilzer <ddkilzer@kilzer.net>\nAcked-by: Eric Wong <normalperson@yhbt.net>\n---\n t/t9119-git-svn-info.sh |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh\nindex cc61911..964011e 100755\n--- a/t/t9119-git-svn-info.sh\n+++ b/t/t9119-git-svn-info.sh\n@@ -11,11 +11,18 @@ test_done\n ptouch() {\n \tperl -w -e '\n \t\tuse strict;\n+\t\tuse POSIX qw(mktime);\n \t\tdie \"ptouch requires exactly 2 arguments\" if @ARGV != 2;\n-\t\tdie \"$ARGV[0] does not exist\" if ! -e $ARGV[0];\n-\t\tmy @s = stat $ARGV[0];\n-\t\tutime $s[8], $s[9], $ARGV[1];\n-\t' \"$1\" \"$2\"\n+\t\tmy $text_last_updated = shift @ARGV;\n+\t\tmy $git_file = shift @ARGV;\n+\t\tdie \"\\\"$git_file\\\" does not exist\" if ! -e $git_file;\n+\t\tif ($text_last_updated\n+\t\t    =~ /(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/) {\n+\t\t\tmy $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);\n+\t\t\tmy $atime = $mtime;\n+\t\t\tutime $atime, $mtime, $git_file;\n+\t\t}\n+\t' \"`svn info $2 | grep '^Text Last Updated:'`\" \"$1\"\n }\n \n test_expect_success 'setup repository and import' \"\n-- \n1.6.0.rc1.69.g797ea\n"},{"id":"86263","messageId":"1217921718-25011-3-git-send-email-normalperson@yhbt.net","threadId":"14837","inReplyTo":"1217921718-25011-1-git-send-email-normalperson@yhbt.net","subject":"[PATCH 3/3] t9119: conditionally re-enable test depending on svn(1) version","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-08-05T07:35:18Z","receivedAt":"2008-08-05T07:35:18Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"I've tested this with svn 1.4.4\n\nThis also adds quoting to make it work odd characters\nin the trash path.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n t/t9119-git-svn-info.sh |   69 +++++++++++++++++++++++++++-------------------\n 1 files changed, 40 insertions(+), 29 deletions(-)\n\ndiff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh\nindex 964011e..5fd36a1 100755\n--- a/t/t9119-git-svn-info.sh\n+++ b/t/t9119-git-svn-info.sh\n@@ -5,8 +5,19 @@\n test_description='git-svn info'\n \n . ./lib-git-svn.sh\n-say 'skipping svn-info test (has a race undiagnosed yet)'\n-test_done\n+\n+set -e\n+\n+# Tested with: svn, version 1.4.4 (r25188)\n+v=`svn --version | sed -n -e 's/^svn, version \\(1\\.4\\.[0-9]\\).*$/\\1/p'`\n+case $v in\n+1.4.*)\n+\t;;\n+*)\n+\tsay \"skipping svn-info test (SVN version: $v not supported)\"\n+\ttest_done\n+\t;;\n+esac\n \n ptouch() {\n \tperl -w -e '\n@@ -25,7 +36,7 @@ ptouch() {\n \t' \"`svn info $2 | grep '^Text Last Updated:'`\" \"$1\"\n }\n \n-test_expect_success 'setup repository and import' \"\n+test_expect_success 'setup repository and import' '\n \tmkdir info &&\n \tcd info &&\n \t\techo FIRST > A &&\n@@ -34,19 +45,19 @@ test_expect_success 'setup repository and import' \"\n \t\tmkdir directory &&\n \t\ttouch directory/.placeholder &&\n \t\tln -s directory symlink-directory &&\n-\t\tsvn import -m 'initial' . $svnrepo &&\n+\t\tsvn import -m \"initial\" . \"$svnrepo\" &&\n \tcd .. &&\n \tmkdir gitwc &&\n \tcd gitwc &&\n-\t\tgit-svn init $svnrepo &&\n+\t\tgit-svn init \"$svnrepo\" &&\n \t\tgit-svn fetch &&\n \tcd .. &&\n-\tsvn co $svnrepo svnwc &&\n+\tsvn co \"$svnrepo\" svnwc &&\n \tptouch svnwc/file gitwc/file &&\n \tptouch svnwc/directory gitwc/directory &&\n \tptouch svnwc/symlink-file gitwc/symlink-file &&\n \tptouch svnwc/symlink-directory gitwc/symlink-directory\n-\t\"\n+\t'\n \n test_expect_success 'info' \"\n \t(cd svnwc; svn info) > expected.info &&\n@@ -55,7 +66,7 @@ test_expect_success 'info' \"\n \t\"\n \n test_expect_success 'info --url' '\n-\ttest $(cd gitwc; git-svn info --url) = $svnrepo\n+\ttest \"$(cd gitwc; git-svn info --url)\" = \"$svnrepo\"\n \t'\n \n test_expect_success 'info .' \"\n@@ -65,7 +76,7 @@ test_expect_success 'info .' \"\n \t\"\n \n test_expect_success 'info --url .' '\n-\ttest $(cd gitwc; git-svn info --url .) = $svnrepo\n+\ttest \"$(cd gitwc; git-svn info --url .)\" = \"$svnrepo\"\n \t'\n \n test_expect_success 'info file' \"\n@@ -75,7 +86,7 @@ test_expect_success 'info file' \"\n \t\"\n \n test_expect_success 'info --url file' '\n-\ttest $(cd gitwc; git-svn info --url file) = \"$svnrepo/file\"\n+\ttest \"$(cd gitwc; git-svn info --url file)\" = \"$svnrepo/file\"\n \t'\n \n test_expect_success 'info directory' \"\n@@ -85,7 +96,7 @@ test_expect_success 'info directory' \"\n \t\"\n \n test_expect_success 'info --url directory' '\n-\ttest $(cd gitwc; git-svn info --url directory) = \"$svnrepo/directory\"\n+\ttest \"$(cd gitwc; git-svn info --url directory)\" = \"$svnrepo/directory\"\n \t'\n \n test_expect_success 'info symlink-file' \"\n@@ -95,7 +106,7 @@ test_expect_success 'info symlink-file' \"\n \t\"\n \n test_expect_success 'info --url symlink-file' '\n-\ttest $(cd gitwc; git-svn info --url symlink-file) \\\n+\ttest \"$(cd gitwc; git-svn info --url symlink-file)\" \\\n \t     = \"$svnrepo/symlink-file\"\n \t'\n \n@@ -108,7 +119,7 @@ test_expect_success 'info symlink-directory' \"\n \t\"\n \n test_expect_success 'info --url symlink-directory' '\n-\ttest $(cd gitwc; git-svn info --url symlink-directory) \\\n+\ttest \"$(cd gitwc; git-svn info --url symlink-directory)\" \\\n \t     = \"$svnrepo/symlink-directory\"\n \t'\n \n@@ -128,7 +139,7 @@ test_expect_success 'info added-file' \"\n \t\"\n \n test_expect_success 'info --url added-file' '\n-\ttest $(cd gitwc; git-svn info --url added-file) \\\n+\ttest \"$(cd gitwc; git-svn info --url added-file)\" \\\n \t     = \"$svnrepo/added-file\"\n \t'\n \n@@ -150,7 +161,7 @@ test_expect_success 'info added-directory' \"\n \t\"\n \n test_expect_success 'info --url added-directory' '\n-\ttest $(cd gitwc; git-svn info --url added-directory) \\\n+\ttest \"$(cd gitwc; git-svn info --url added-directory)\" \\\n \t     = \"$svnrepo/added-directory\"\n \t'\n \n@@ -173,7 +184,7 @@ test_expect_success 'info added-symlink-file' \"\n \t\"\n \n test_expect_success 'info --url added-symlink-file' '\n-\ttest $(cd gitwc; git-svn info --url added-symlink-file) \\\n+\ttest \"$(cd gitwc; git-svn info --url added-symlink-file)\" \\\n \t     = \"$svnrepo/added-symlink-file\"\n \t'\n \n@@ -196,7 +207,7 @@ test_expect_success 'info added-symlink-directory' \"\n \t\"\n \n test_expect_success 'info --url added-symlink-directory' '\n-\ttest $(cd gitwc; git-svn info --url added-symlink-directory) \\\n+\ttest \"$(cd gitwc; git-svn info --url added-symlink-directory)\" \\\n \t     = \"$svnrepo/added-symlink-directory\"\n \t'\n \n@@ -222,7 +233,7 @@ test_expect_success 'info deleted-file' \"\n \t\"\n \n test_expect_success 'info --url file (deleted)' '\n-\ttest $(cd gitwc; git-svn info --url file) \\\n+\ttest \"$(cd gitwc; git-svn info --url file)\" \\\n \t     = \"$svnrepo/file\"\n \t'\n \n@@ -243,7 +254,7 @@ test_expect_success 'info deleted-directory' \"\n \t\"\n \n test_expect_success 'info --url directory (deleted)' '\n-\ttest $(cd gitwc; git-svn info --url directory) \\\n+\ttest \"$(cd gitwc; git-svn info --url directory)\" \\\n \t     = \"$svnrepo/directory\"\n \t'\n \n@@ -265,7 +276,7 @@ test_expect_success 'info deleted-symlink-file' \"\n \t\"\n \n test_expect_success 'info --url symlink-file (deleted)' '\n-\ttest $(cd gitwc; git-svn info --url symlink-file) \\\n+\ttest \"$(cd gitwc; git-svn info --url symlink-file)\" \\\n \t     = \"$svnrepo/symlink-file\"\n \t'\n \n@@ -287,7 +298,7 @@ test_expect_success 'info deleted-symlink-directory' \"\n \t\"\n \n test_expect_success 'info --url symlink-directory (deleted)' '\n-\ttest $(cd gitwc; git-svn info --url symlink-directory) \\\n+\ttest \"$(cd gitwc; git-svn info --url symlink-directory)\" \\\n \t     = \"$svnrepo/symlink-directory\"\n \t'\n \n@@ -304,8 +315,8 @@ test_expect_success 'info unknown-file' \"\n \t\"\n \n test_expect_success 'info --url unknown-file' '\n-\ttest -z $(cd gitwc; git-svn info --url unknown-file \\\n-\t\t\t2> ../actual.info--url-unknown-file) &&\n+\ttest -z \"$(cd gitwc; git-svn info --url unknown-file \\\n+\t\t\t2> ../actual.info--url-unknown-file)\" &&\n \tgit-diff expected.info-unknown-file actual.info--url-unknown-file\n \t'\n \n@@ -321,8 +332,8 @@ test_expect_success 'info unknown-directory' \"\n \t\"\n \n test_expect_success 'info --url unknown-directory' '\n-\ttest -z $(cd gitwc; git-svn info --url unknown-directory \\\n-\t\t\t2> ../actual.info--url-unknown-directory) &&\n+\ttest -z \"$(cd gitwc; git-svn info --url unknown-directory \\\n+\t\t\t2> ../actual.info--url-unknown-directory)\" &&\n \tgit-diff expected.info-unknown-directory \\\n \t\t actual.info--url-unknown-directory\n \t'\n@@ -344,8 +355,8 @@ test_expect_success 'info unknown-symlink-file' \"\n \t\"\n \n test_expect_success 'info --url unknown-symlink-file' '\n-\ttest -z $(cd gitwc; git-svn info --url unknown-symlink-file \\\n-\t\t\t2> ../actual.info--url-unknown-symlink-file) &&\n+\ttest -z \"$(cd gitwc; git-svn info --url unknown-symlink-file \\\n+\t\t\t2> ../actual.info--url-unknown-symlink-file)\" &&\n \tgit-diff expected.info-unknown-symlink-file \\\n \t\t actual.info--url-unknown-symlink-file\n \t'\n@@ -368,8 +379,8 @@ test_expect_success 'info unknown-symlink-directory' \"\n \t\"\n \n test_expect_success 'info --url unknown-symlink-directory' '\n-\ttest -z $(cd gitwc; git-svn info --url unknown-symlink-directory \\\n-\t\t\t2> ../actual.info--url-unknown-symlink-directory) &&\n+\ttest -z \"$(cd gitwc; git-svn info --url unknown-symlink-directory \\\n+\t\t\t2> ../actual.info--url-unknown-symlink-directory)\" &&\n \tgit-diff expected.info-unknown-symlink-directory \\\n \t\t actual.info--url-unknown-symlink-directory\n \t'\n-- \n1.6.0.rc1.69.g797ea\n"}]}