[PATCH 1/3] git-svn: properly set path for "info" command

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/3] git-svn: properly set path for "info" command

Eric Wong
canonicalize_path() was previously changed to better
fit SVN 1.5, but it makes the "info" command not match
svn(1) in two places:

  1) URL ended up with a trailing slash when run without an
     argument.

  2) "Path: " was displayed instead of "Path: ." when run
     without an argument.

We will also handle odd cases where a user wants to
get information on a file or directory named "0", too.

Signed-off-by: Eric Wong <[hidden email]>
---
 git-svn.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index cc35f50..df0ed90 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -796,8 +796,8 @@ sub cmd_commit_diff {
 }
 
 sub cmd_info {
- my $path = canonicalize_path(shift or ".");
- unless (scalar(@_) == 0) {
+ my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
+ if (exists $_[1]) {
  die "Too many arguments specified\n";
  }
 
@@ -813,6 +813,10 @@ sub cmd_info {
  die "Unable to determine upstream SVN information from ",
     "working tree history\n";
  }
+
+ # canonicalize_path() will return "" to make libsvn 1.5.x happy,
+ $path = "." if $path eq "";
+
  my $full_url = $url . ($path eq "." ? "" : "/$path");
 
  if ($_url) {
--
1.6.0.rc1.69.g797ea

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Eric Wong
From: David D. Kilzer <[hidden email]>

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.

[ew: swapped argument order of ptouch() to minimize diff]

From: David D. Kilzer <[hidden email]>

Signed-off-by: David D. Kilzer <[hidden email]>
Acked-by: Eric Wong <[hidden email]>
---
 t/t9119-git-svn-info.sh |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index cc61911..964011e 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -11,11 +11,18 @@ 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 $2 | grep '^Text Last Updated:'`" "$1"
 }
 
 test_expect_success 'setup repository and import' "
--
1.6.0.rc1.69.g797ea

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3] t9119: conditionally re-enable test depending on svn(1) version

Eric Wong
In reply to this post by Eric Wong
I've tested this with svn 1.4.4

This also adds quoting to make it work odd characters
in the trash path.

Signed-off-by: Eric Wong <[hidden email]>
---
 t/t9119-git-svn-info.sh |   69 +++++++++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index 964011e..5fd36a1 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -5,8 +5,19 @@
 test_description='git-svn info'
 
 . ./lib-git-svn.sh
-say 'skipping svn-info test (has a race undiagnosed yet)'
-test_done
+
+set -e
+
+# Tested with: svn, version 1.4.4 (r25188)
+v=`svn --version | sed -n -e 's/^svn, version \(1\.4\.[0-9]\).*$/\1/p'`
+case $v in
+1.4.*)
+ ;;
+*)
+ say "skipping svn-info test (SVN version: $v not supported)"
+ test_done
+ ;;
+esac
 
 ptouch() {
  perl -w -e '
@@ -25,7 +36,7 @@ ptouch() {
  ' "`svn info $2 | grep '^Text Last Updated:'`" "$1"
 }
 
-test_expect_success 'setup repository and import' "
+test_expect_success 'setup repository and import' '
  mkdir info &&
  cd info &&
  echo FIRST > A &&
@@ -34,19 +45,19 @@ test_expect_success 'setup repository and import' "
  mkdir directory &&
  touch directory/.placeholder &&
  ln -s directory symlink-directory &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
  cd .. &&
  mkdir gitwc &&
  cd gitwc &&
- git-svn init $svnrepo &&
+ git-svn init "$svnrepo" &&
  git-svn fetch &&
  cd .. &&
- svn co $svnrepo svnwc &&
+ svn co "$svnrepo" svnwc &&
  ptouch svnwc/file gitwc/file &&
  ptouch svnwc/directory gitwc/directory &&
  ptouch svnwc/symlink-file gitwc/symlink-file &&
  ptouch svnwc/symlink-directory gitwc/symlink-directory
- "
+ '
 
 test_expect_success 'info' "
  (cd svnwc; svn info) > expected.info &&
@@ -55,7 +66,7 @@ test_expect_success 'info' "
  "
 
 test_expect_success 'info --url' '
- test $(cd gitwc; git-svn info --url) = $svnrepo
+ test "$(cd gitwc; git-svn info --url)" = "$svnrepo"
  '
 
 test_expect_success 'info .' "
@@ -65,7 +76,7 @@ test_expect_success 'info .' "
  "
 
 test_expect_success 'info --url .' '
- test $(cd gitwc; git-svn info --url .) = $svnrepo
+ test "$(cd gitwc; git-svn info --url .)" = "$svnrepo"
  '
 
 test_expect_success 'info file' "
@@ -75,7 +86,7 @@ test_expect_success 'info file' "
  "
 
 test_expect_success 'info --url file' '
- test $(cd gitwc; git-svn info --url file) = "$svnrepo/file"
+ test "$(cd gitwc; git-svn info --url file)" = "$svnrepo/file"
  '
 
 test_expect_success 'info directory' "
@@ -85,7 +96,7 @@ test_expect_success 'info directory' "
  "
 
 test_expect_success 'info --url directory' '
- test $(cd gitwc; git-svn info --url directory) = "$svnrepo/directory"
+ test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
  '
 
 test_expect_success 'info symlink-file' "
@@ -95,7 +106,7 @@ test_expect_success 'info symlink-file' "
  "
 
 test_expect_success 'info --url symlink-file' '
- test $(cd gitwc; git-svn info --url symlink-file) \
+ test "$(cd gitwc; git-svn info --url symlink-file)" \
      = "$svnrepo/symlink-file"
  '
 
@@ -108,7 +119,7 @@ test_expect_success 'info symlink-directory' "
  "
 
 test_expect_success 'info --url symlink-directory' '
- test $(cd gitwc; git-svn info --url symlink-directory) \
+ test "$(cd gitwc; git-svn info --url symlink-directory)" \
      = "$svnrepo/symlink-directory"
  '
 
@@ -128,7 +139,7 @@ test_expect_success 'info added-file' "
  "
 
 test_expect_success 'info --url added-file' '
- test $(cd gitwc; git-svn info --url added-file) \
+ test "$(cd gitwc; git-svn info --url added-file)" \
      = "$svnrepo/added-file"
  '
 
@@ -150,7 +161,7 @@ test_expect_success 'info added-directory' "
  "
 
 test_expect_success 'info --url added-directory' '
- test $(cd gitwc; git-svn info --url added-directory) \
+ test "$(cd gitwc; git-svn info --url added-directory)" \
      = "$svnrepo/added-directory"
  '
 
@@ -173,7 +184,7 @@ test_expect_success 'info added-symlink-file' "
  "
 
 test_expect_success 'info --url added-symlink-file' '
- test $(cd gitwc; git-svn info --url added-symlink-file) \
+ test "$(cd gitwc; git-svn info --url added-symlink-file)" \
      = "$svnrepo/added-symlink-file"
  '
 
@@ -196,7 +207,7 @@ test_expect_success 'info added-symlink-directory' "
  "
 
 test_expect_success 'info --url added-symlink-directory' '
- test $(cd gitwc; git-svn info --url added-symlink-directory) \
+ test "$(cd gitwc; git-svn info --url added-symlink-directory)" \
      = "$svnrepo/added-symlink-directory"
  '
 
@@ -222,7 +233,7 @@ test_expect_success 'info deleted-file' "
  "
 
 test_expect_success 'info --url file (deleted)' '
- test $(cd gitwc; git-svn info --url file) \
+ test "$(cd gitwc; git-svn info --url file)" \
      = "$svnrepo/file"
  '
 
@@ -243,7 +254,7 @@ test_expect_success 'info deleted-directory' "
  "
 
 test_expect_success 'info --url directory (deleted)' '
- test $(cd gitwc; git-svn info --url directory) \
+ test "$(cd gitwc; git-svn info --url directory)" \
      = "$svnrepo/directory"
  '
 
@@ -265,7 +276,7 @@ test_expect_success 'info deleted-symlink-file' "
  "
 
 test_expect_success 'info --url symlink-file (deleted)' '
- test $(cd gitwc; git-svn info --url symlink-file) \
+ test "$(cd gitwc; git-svn info --url symlink-file)" \
      = "$svnrepo/symlink-file"
  '
 
@@ -287,7 +298,7 @@ test_expect_success 'info deleted-symlink-directory' "
  "
 
 test_expect_success 'info --url symlink-directory (deleted)' '
- test $(cd gitwc; git-svn info --url symlink-directory) \
+ test "$(cd gitwc; git-svn info --url symlink-directory)" \
      = "$svnrepo/symlink-directory"
  '
 
@@ -304,8 +315,8 @@ test_expect_success 'info unknown-file' "
  "
 
 test_expect_success 'info --url unknown-file' '
- test -z $(cd gitwc; git-svn info --url unknown-file \
- 2> ../actual.info--url-unknown-file) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-file \
+ 2> ../actual.info--url-unknown-file)" &&
  git-diff expected.info-unknown-file actual.info--url-unknown-file
  '
 
@@ -321,8 +332,8 @@ test_expect_success 'info unknown-directory' "
  "
 
 test_expect_success 'info --url unknown-directory' '
- test -z $(cd gitwc; git-svn info --url unknown-directory \
- 2> ../actual.info--url-unknown-directory) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-directory \
+ 2> ../actual.info--url-unknown-directory)" &&
  git-diff expected.info-unknown-directory \
  actual.info--url-unknown-directory
  '
@@ -344,8 +355,8 @@ test_expect_success 'info unknown-symlink-file' "
  "
 
 test_expect_success 'info --url unknown-symlink-file' '
- test -z $(cd gitwc; git-svn info --url unknown-symlink-file \
- 2> ../actual.info--url-unknown-symlink-file) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-symlink-file \
+ 2> ../actual.info--url-unknown-symlink-file)" &&
  git-diff expected.info-unknown-symlink-file \
  actual.info--url-unknown-symlink-file
  '
@@ -368,8 +379,8 @@ test_expect_success 'info unknown-symlink-directory' "
  "
 
 test_expect_success 'info --url unknown-symlink-directory' '
- test -z $(cd gitwc; git-svn info --url unknown-symlink-directory \
- 2> ../actual.info--url-unknown-symlink-directory) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-symlink-directory \
+ 2> ../actual.info--url-unknown-symlink-directory)" &&
  git-diff expected.info-unknown-symlink-directory \
  actual.info--url-unknown-symlink-directory
  '
--
1.6.0.rc1.69.g797ea

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html