Fix parsing of @{-1}@{1}
[gitweb.git] / t / t9119-git-svn-info.sh
index 5fd36a148304e4532f4e1b30deac781028c68271..27dd7c273a4a1ae77a8e48b2e4b4ce1a3ae19a56 100755 (executable)
@@ -2,16 +2,14 @@
 #
 # Copyright (c) 2007 David D. Kilzer
 
-test_description='git-svn info'
+test_description='git svn info'
 
 . ./lib-git-svn.sh
 
-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'`
+v=`svn --version | sed -n -e 's/^svn, version \(1\.[0-9]*\.[0-9]*\).*$/\1/p'`
 case $v in
-1.4.*)
+1.[45].*)
        ;;
 *)
        say "skipping svn-info test (SVN version: $v not supported)"
@@ -36,6 +34,8 @@ ptouch() {
        ' "`svn info $2 | grep '^Text Last Updated:'`" "$1"
 }
 
+quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')"
+
 test_expect_success 'setup repository and import' '
        mkdir info &&
        cd info &&
@@ -47,80 +47,92 @@ test_expect_success 'setup repository and import' '
                ln -s directory symlink-directory &&
                svn import -m "initial" . "$svnrepo" &&
        cd .. &&
+       svn co "$svnrepo" svnwc &&
+       cd svnwc &&
+               echo foo > foo &&
+               svn add foo &&
+               svn commit -m "change outside directory" &&
+               svn update &&
+       cd .. &&
        mkdir gitwc &&
        cd gitwc &&
-               git-svn init "$svnrepo" &&
-               git-svn fetch &&
+               git svn init "$svnrepo" &&
+               git svn fetch &&
        cd .. &&
-       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
+       ptouch gitwc/file svnwc/file &&
+       ptouch gitwc/directory svnwc/directory &&
+       ptouch gitwc/symlink-file svnwc/symlink-file &&
+       ptouch gitwc/symlink-directory svnwc/symlink-directory
        '
 
 test_expect_success 'info' "
        (cd svnwc; svn info) > expected.info &&
-       (cd gitwc; git-svn info) > actual.info &&
-       git-diff expected.info actual.info
+       (cd gitwc; git svn info) > actual.info &&
+       test_cmp expected.info actual.info
        "
 
 test_expect_success 'info --url' '
-       test "$(cd gitwc; git-svn info --url)" = "$svnrepo"
+       test "$(cd gitwc; git svn info --url)" = "$quoted_svnrepo"
        '
 
 test_expect_success 'info .' "
        (cd svnwc; svn info .) > expected.info-dot &&
-       (cd gitwc; git-svn info .) > actual.info-dot &&
-       git-diff expected.info-dot actual.info-dot
+       (cd gitwc; git svn info .) > actual.info-dot &&
+       test_cmp expected.info-dot actual.info-dot
        "
 
 test_expect_success 'info --url .' '
-       test "$(cd gitwc; git-svn info --url .)" = "$svnrepo"
+       test "$(cd gitwc; git svn info --url .)" = "$quoted_svnrepo"
        '
 
 test_expect_success 'info file' "
        (cd svnwc; svn info file) > expected.info-file &&
-       (cd gitwc; git-svn info file) > actual.info-file &&
-       git-diff expected.info-file actual.info-file
+       (cd gitwc; git svn info file) > actual.info-file &&
+       test_cmp expected.info-file actual.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)" = "$quoted_svnrepo/file"
        '
 
 test_expect_success 'info directory' "
        (cd svnwc; svn info directory) > expected.info-directory &&
-       (cd gitwc; git-svn info directory) > actual.info-directory &&
-       git-diff expected.info-directory actual.info-directory
+       (cd gitwc; git svn info directory) > actual.info-directory &&
+       test_cmp expected.info-directory actual.info-directory
+       "
+
+test_expect_success 'info inside directory' "
+       (cd svnwc/directory; svn info) > expected.info-inside-directory &&
+       (cd gitwc/directory; git svn info) > actual.info-inside-directory &&
+       test_cmp expected.info-inside-directory actual.info-inside-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)" = "$quoted_svnrepo/directory"
        '
 
 test_expect_success 'info symlink-file' "
        (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
-       (cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
-       git-diff expected.info-symlink-file actual.info-symlink-file
+       (cd gitwc; git svn info symlink-file) > actual.info-symlink-file &&
+       test_cmp expected.info-symlink-file actual.info-symlink-file
        "
 
 test_expect_success 'info --url symlink-file' '
-       test "$(cd gitwc; git-svn info --url symlink-file)" \
-            = "$svnrepo/symlink-file"
+       test "$(cd gitwc; git svn info --url symlink-file)" \
+            = "$quoted_svnrepo/symlink-file"
        '
 
 test_expect_success 'info symlink-directory' "
        (cd svnwc; svn info symlink-directory) \
                > expected.info-symlink-directory &&
-       (cd gitwc; git-svn info symlink-directory) \
+       (cd gitwc; git svn info symlink-directory) \
                > actual.info-symlink-directory &&
-       git-diff expected.info-symlink-directory actual.info-symlink-directory
+       test_cmp expected.info-symlink-directory actual.info-symlink-directory
        "
 
 test_expect_success 'info --url symlink-directory' '
-       test "$(cd gitwc; git-svn info --url symlink-directory)" \
-            = "$svnrepo/symlink-directory"
+       test "$(cd gitwc; git svn info --url symlink-directory)" \
+            = "$quoted_svnrepo/symlink-directory"
        '
 
 test_expect_success 'info added-file' "
@@ -134,13 +146,13 @@ test_expect_success 'info added-file' "
                svn add added-file > /dev/null &&
        cd .. &&
        (cd svnwc; svn info added-file) > expected.info-added-file &&
-       (cd gitwc; git-svn info added-file) > actual.info-added-file &&
-       git-diff expected.info-added-file actual.info-added-file
+       (cd gitwc; git svn info added-file) > actual.info-added-file &&
+       test_cmp expected.info-added-file actual.info-added-file
        "
 
 test_expect_success 'info --url added-file' '
-       test "$(cd gitwc; git-svn info --url added-file)" \
-            = "$svnrepo/added-file"
+       test "$(cd gitwc; git svn info --url added-file)" \
+            = "$quoted_svnrepo/added-file"
        '
 
 test_expect_success 'info added-directory' "
@@ -155,14 +167,14 @@ test_expect_success 'info added-directory' "
        cd .. &&
        (cd svnwc; svn info added-directory) \
                > expected.info-added-directory &&
-       (cd gitwc; git-svn info added-directory) \
+       (cd gitwc; git svn info added-directory) \
                > actual.info-added-directory &&
-       git-diff expected.info-added-directory actual.info-added-directory
+       test_cmp expected.info-added-directory actual.info-added-directory
        "
 
 test_expect_success 'info --url added-directory' '
-       test "$(cd gitwc; git-svn info --url added-directory)" \
-            = "$svnrepo/added-directory"
+       test "$(cd gitwc; git svn info --url added-directory)" \
+            = "$quoted_svnrepo/added-directory"
        '
 
 test_expect_success 'info added-symlink-file' "
@@ -177,15 +189,15 @@ test_expect_success 'info added-symlink-file' "
        ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
        (cd svnwc; svn info added-symlink-file) \
                > expected.info-added-symlink-file &&
-       (cd gitwc; git-svn info added-symlink-file) \
+       (cd gitwc; git svn info added-symlink-file) \
                > actual.info-added-symlink-file &&
-       git-diff expected.info-added-symlink-file \
+       test_cmp expected.info-added-symlink-file \
                 actual.info-added-symlink-file
        "
 
 test_expect_success 'info --url added-symlink-file' '
-       test "$(cd gitwc; git-svn info --url added-symlink-file)" \
-            = "$svnrepo/added-symlink-file"
+       test "$(cd gitwc; git svn info --url added-symlink-file)" \
+            = "$quoted_svnrepo/added-symlink-file"
        '
 
 test_expect_success 'info added-symlink-directory' "
@@ -200,15 +212,15 @@ test_expect_success 'info added-symlink-directory' "
        ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
        (cd svnwc; svn info added-symlink-directory) \
                > expected.info-added-symlink-directory &&
-       (cd gitwc; git-svn info added-symlink-directory) \
+       (cd gitwc; git svn info added-symlink-directory) \
                > actual.info-added-symlink-directory &&
-       git-diff expected.info-added-symlink-directory \
+       test_cmp expected.info-added-symlink-directory \
                 actual.info-added-symlink-directory
        "
 
 test_expect_success 'info --url added-symlink-directory' '
-       test "$(cd gitwc; git-svn info --url added-symlink-directory)" \
-            = "$svnrepo/added-symlink-directory"
+       test "$(cd gitwc; git svn info --url added-symlink-directory)" \
+            = "$quoted_svnrepo/added-symlink-directory"
        '
 
 # The next few tests replace the "Text Last Updated" value with a
@@ -226,15 +238,15 @@ test_expect_success 'info deleted-file' "
        (cd svnwc; svn info file) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > expected.info-deleted-file &&
-       (cd gitwc; git-svn info file) |
+       (cd gitwc; git svn info file) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > actual.info-deleted-file &&
-       git-diff expected.info-deleted-file actual.info-deleted-file
+       test_cmp expected.info-deleted-file actual.info-deleted-file
        "
 
 test_expect_success 'info --url file (deleted)' '
-       test "$(cd gitwc; git-svn info --url file)" \
-            = "$svnrepo/file"
+       test "$(cd gitwc; git svn info --url file)" \
+            = "$quoted_svnrepo/file"
        '
 
 test_expect_success 'info deleted-directory' "
@@ -247,15 +259,15 @@ test_expect_success 'info deleted-directory' "
        (cd svnwc; svn info directory) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > expected.info-deleted-directory &&
-       (cd gitwc; git-svn info directory) |
+       (cd gitwc; git svn info directory) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > actual.info-deleted-directory &&
-       git-diff expected.info-deleted-directory actual.info-deleted-directory
+       test_cmp expected.info-deleted-directory actual.info-deleted-directory
        "
 
 test_expect_success 'info --url directory (deleted)' '
-       test "$(cd gitwc; git-svn info --url directory)" \
-            = "$svnrepo/directory"
+       test "$(cd gitwc; git svn info --url directory)" \
+            = "$quoted_svnrepo/directory"
        '
 
 test_expect_success 'info deleted-symlink-file' "
@@ -268,16 +280,16 @@ test_expect_success 'info deleted-symlink-file' "
        (cd svnwc; svn info symlink-file) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > expected.info-deleted-symlink-file &&
-       (cd gitwc; git-svn info symlink-file) |
+       (cd gitwc; git svn info symlink-file) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                > actual.info-deleted-symlink-file &&
-       git-diff expected.info-deleted-symlink-file \
+       test_cmp expected.info-deleted-symlink-file \
                 actual.info-deleted-symlink-file
        "
 
 test_expect_success 'info --url symlink-file (deleted)' '
-       test "$(cd gitwc; git-svn info --url symlink-file)" \
-            = "$svnrepo/symlink-file"
+       test "$(cd gitwc; git svn info --url symlink-file)" \
+            = "$quoted_svnrepo/symlink-file"
        '
 
 test_expect_success 'info deleted-symlink-directory' "
@@ -290,16 +302,16 @@ test_expect_success 'info deleted-symlink-directory' "
        (cd svnwc; svn info symlink-directory) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                 > expected.info-deleted-symlink-directory &&
-       (cd gitwc; git-svn info symlink-directory) |
+       (cd gitwc; git svn info symlink-directory) |
        sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
                 > actual.info-deleted-symlink-directory &&
-       git-diff expected.info-deleted-symlink-directory \
+       test_cmp expected.info-deleted-symlink-directory \
                 actual.info-deleted-symlink-directory
        "
 
 test_expect_success 'info --url symlink-directory (deleted)' '
-       test "$(cd gitwc; git-svn info --url symlink-directory)" \
-            = "$svnrepo/symlink-directory"
+       test "$(cd gitwc; git svn info --url symlink-directory)" \
+            = "$quoted_svnrepo/symlink-directory"
        '
 
 # NOTE: git does not have the concept of replaced objects,
@@ -307,82 +319,59 @@ 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 &&
-       (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
+       (cd gitwc; test_must_fail git svn info unknown-file) \
+                2> actual.info-unknown-file &&
+       grep unknown-file actual.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)" &&
-       git-diff expected.info-unknown-file actual.info--url-unknown-file
+       echo two > gitwc/unknown-file &&
+       (cd gitwc; test_must_fail git svn info --url unknown-file) \
+                2> actual.info-url-unknown-file &&
+       grep unknown-file actual.info-url-unknown-file
        '
 
 test_expect_success 'info unknown-directory' "
        mkdir gitwc/unknown-directory svnwc/unknown-directory &&
-       ptouch gitwc/unknown-directory svnwc/unknown-directory &&
-       touch gitwc/unknown-directory/.placeholder &&
-       (cd svnwc; svn info unknown-directory) \
-               2> expected.info-unknown-directory &&
-       (cd gitwc; git-svn info unknown-directory) \
-               2> actual.info-unknown-directory &&
-       git-diff expected.info-unknown-directory actual.info-unknown-directory
+       (cd gitwc; test_must_fail git svn info unknown-directory) \
+                2> actual.info-unknown-directory &&
+       grep unknown-directory actual.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)" &&
-       git-diff expected.info-unknown-directory \
-                actual.info--url-unknown-directory
+       (cd gitwc; test_must_fail git svn info --url unknown-directory) \
+                2> actual.info-url-unknown-directory &&
+       grep unknown-directory actual.info-url-unknown-directory
        '
 
 test_expect_success 'info unknown-symlink-file' "
        cd gitwc &&
                ln -s unknown-file unknown-symlink-file &&
        cd .. &&
-       cd svnwc &&
-               ln -s unknown-file unknown-symlink-file &&
-       cd .. &&
-       ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
-       (cd svnwc; svn info unknown-symlink-file) \
-               2> expected.info-unknown-symlink-file &&
-       (cd gitwc; git-svn info unknown-symlink-file) \
-               2> actual.info-unknown-symlink-file &&
-       git-diff expected.info-unknown-symlink-file \
-                actual.info-unknown-symlink-file
+       (cd gitwc; test_must_fail git svn info unknown-symlink-file) \
+                2> actual.info-unknown-symlink-file &&
+       grep unknown-symlink-file actual.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)" &&
-       git-diff expected.info-unknown-symlink-file \
-                actual.info--url-unknown-symlink-file
+       (cd gitwc; test_must_fail git svn info --url unknown-symlink-file) \
+                2> actual.info-url-unknown-symlink-file &&
+       grep unknown-symlink-file actual.info-url-unknown-symlink-file
        '
 
 test_expect_success 'info unknown-symlink-directory' "
        cd gitwc &&
                ln -s unknown-directory unknown-symlink-directory &&
        cd .. &&
-       cd svnwc &&
-               ln -s unknown-directory unknown-symlink-directory &&
-       cd .. &&
-       ptouch gitwc/unknown-symlink-directory \
-              svnwc/unknown-symlink-directory &&
-       (cd svnwc; svn info unknown-symlink-directory) \
-               2> expected.info-unknown-symlink-directory &&
-       (cd gitwc; git-svn info unknown-symlink-directory) \
-               2> actual.info-unknown-symlink-directory &&
-       git-diff expected.info-unknown-symlink-directory \
-                actual.info-unknown-symlink-directory
+       (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \
+                2> actual.info-unknown-symlink-directory &&
+       grep unknown-symlink-directory actual.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)" &&
-       git-diff expected.info-unknown-symlink-directory \
-                actual.info--url-unknown-symlink-directory
+       (cd gitwc; test_must_fail git svn info --url unknown-symlink-directory) \
+                2> actual.info-url-unknown-symlink-directory &&
+       grep unknown-symlink-directory actual.info-url-unknown-symlink-directory
        '
 
 test_done