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 '
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' "
+test_expect_success 'setup repository and import' '
mkdir info &&
cd info &&
echo FIRST > A &&
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 &&
"
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 .' "
"
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' "
"
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' "
"
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' "
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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"
'
"
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
'
"
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
'
"
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
'
"
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
'