t / t9119-git-svn-info.shon commit Merge branch 'db/delta-applier' into svn-fe (a8d3d26)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 David D. Kilzer
   4
   5test_description='git svn info'
   6
   7. ./lib-git-svn.sh
   8
   9# Tested with: svn, version 1.4.4 (r25188)
  10# Tested with: svn, version 1.6.[12345689]
  11v=`svn_cmd --version | sed -n -e 's/^svn, version \(1\.[0-9]*\.[0-9]*\).*$/\1/p'`
  12case $v in
  131.[456].*)
  14        ;;
  15*)
  16        skip_all="skipping svn-info test (SVN version: $v not supported)"
  17        test_done
  18        ;;
  19esac
  20
  21# On the "Text Last Updated" line, "git svn info" does not return the
  22# same value as "svn info" (i.e. the commit timestamp that touched the
  23# path most recently); do not expect that field to match.
  24test_cmp_info () {
  25        sed -e '/^Text Last Updated:/d' "$1" >tmp.expect
  26        sed -e '/^Text Last Updated:/d' "$2" >tmp.actual
  27        test_cmp tmp.expect tmp.actual &&
  28        rm -f tmp.expect tmp.actual
  29}
  30
  31quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')"
  32
  33test_expect_success 'setup repository and import' '
  34        mkdir info &&
  35        (
  36                cd info &&
  37                echo FIRST >A &&
  38                echo one >file &&
  39                ln -s file symlink-file &&
  40                mkdir directory &&
  41                touch directory/.placeholder &&
  42                ln -s directory symlink-directory &&
  43                svn_cmd import -m "initial" . "$svnrepo"
  44        ) &&
  45        svn_cmd co "$svnrepo" svnwc &&
  46        (
  47                cd svnwc &&
  48                echo foo >foo &&
  49                svn_cmd add foo &&
  50                svn_cmd commit -m "change outside directory" &&
  51                svn_cmd update
  52        ) &&
  53        mkdir gitwc &&
  54        (
  55                cd gitwc &&
  56                git svn init "$svnrepo" &&
  57                git svn fetch
  58        )
  59        '
  60
  61test_expect_success 'info' "
  62        (cd svnwc; svn info) > expected.info &&
  63        (cd gitwc; git svn info) > actual.info &&
  64        test_cmp_info expected.info actual.info
  65        "
  66
  67test_expect_success 'info --url' '
  68        test "$(cd gitwc; git svn info --url)" = "$quoted_svnrepo"
  69        '
  70
  71test_expect_success 'info .' "
  72        (cd svnwc; svn info .) > expected.info-dot &&
  73        (cd gitwc; git svn info .) > actual.info-dot &&
  74        test_cmp_info expected.info-dot actual.info-dot
  75        "
  76
  77test_expect_success 'info --url .' '
  78        test "$(cd gitwc; git svn info --url .)" = "$quoted_svnrepo"
  79        '
  80
  81test_expect_success 'info file' "
  82        (cd svnwc; svn info file) > expected.info-file &&
  83        (cd gitwc; git svn info file) > actual.info-file &&
  84        test_cmp_info expected.info-file actual.info-file
  85        "
  86
  87test_expect_success 'info --url file' '
  88        test "$(cd gitwc; git svn info --url file)" = "$quoted_svnrepo/file"
  89        '
  90
  91test_expect_success 'info directory' "
  92        (cd svnwc; svn info directory) > expected.info-directory &&
  93        (cd gitwc; git svn info directory) > actual.info-directory &&
  94        test_cmp_info expected.info-directory actual.info-directory
  95        "
  96
  97test_expect_success 'info inside directory' "
  98        (cd svnwc/directory; svn info) > expected.info-inside-directory &&
  99        (cd gitwc/directory; git svn info) > actual.info-inside-directory &&
 100        test_cmp_info expected.info-inside-directory actual.info-inside-directory
 101        "
 102
 103test_expect_success 'info --url directory' '
 104        test "$(cd gitwc; git svn info --url directory)" = "$quoted_svnrepo/directory"
 105        '
 106
 107test_expect_success 'info symlink-file' "
 108        (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
 109        (cd gitwc; git svn info symlink-file) > actual.info-symlink-file &&
 110        test_cmp_info expected.info-symlink-file actual.info-symlink-file
 111        "
 112
 113test_expect_success 'info --url symlink-file' '
 114        test "$(cd gitwc; git svn info --url symlink-file)" \
 115             = "$quoted_svnrepo/symlink-file"
 116        '
 117
 118test_expect_success 'info symlink-directory' "
 119        (cd svnwc; svn info symlink-directory) \
 120                > expected.info-symlink-directory &&
 121        (cd gitwc; git svn info symlink-directory) \
 122                > actual.info-symlink-directory &&
 123        test_cmp_info expected.info-symlink-directory actual.info-symlink-directory
 124        "
 125
 126test_expect_success 'info --url symlink-directory' '
 127        test "$(cd gitwc; git svn info --url symlink-directory)" \
 128             = "$quoted_svnrepo/symlink-directory"
 129        '
 130
 131test_expect_success 'info added-file' "
 132        echo two > gitwc/added-file &&
 133        (
 134                cd gitwc &&
 135                git add added-file
 136        ) &&
 137        cp gitwc/added-file svnwc/added-file &&
 138        (
 139                cd svnwc &&
 140                svn_cmd add added-file > /dev/null
 141        ) &&
 142        (cd svnwc; svn info added-file) > expected.info-added-file &&
 143        (cd gitwc; git svn info added-file) > actual.info-added-file &&
 144        test_cmp_info expected.info-added-file actual.info-added-file
 145        "
 146
 147test_expect_success 'info --url added-file' '
 148        test "$(cd gitwc; git svn info --url added-file)" \
 149             = "$quoted_svnrepo/added-file"
 150        '
 151
 152test_expect_success 'info added-directory' "
 153        mkdir gitwc/added-directory svnwc/added-directory &&
 154        touch gitwc/added-directory/.placeholder &&
 155        (
 156                cd svnwc &&
 157                svn_cmd add added-directory > /dev/null
 158        ) &&
 159        (
 160                cd gitwc &&
 161                git add added-directory
 162        ) &&
 163        (cd svnwc; svn info added-directory) \
 164                > expected.info-added-directory &&
 165        (cd gitwc; git svn info added-directory) \
 166                > actual.info-added-directory &&
 167        test_cmp_info expected.info-added-directory actual.info-added-directory
 168        "
 169
 170test_expect_success 'info --url added-directory' '
 171        test "$(cd gitwc; git svn info --url added-directory)" \
 172             = "$quoted_svnrepo/added-directory"
 173        '
 174
 175test_expect_success 'info added-symlink-file' "
 176        (
 177                cd gitwc &&
 178                ln -s added-file added-symlink-file &&
 179                git add added-symlink-file
 180        ) &&
 181        (
 182                cd svnwc &&
 183                ln -s added-file added-symlink-file &&
 184                svn_cmd add added-symlink-file > /dev/null
 185        ) &&
 186        (cd svnwc; svn info added-symlink-file) \
 187                > expected.info-added-symlink-file &&
 188        (cd gitwc; git svn info added-symlink-file) \
 189                > actual.info-added-symlink-file &&
 190        test_cmp_info expected.info-added-symlink-file \
 191                actual.info-added-symlink-file
 192        "
 193
 194test_expect_success 'info --url added-symlink-file' '
 195        test "$(cd gitwc; git svn info --url added-symlink-file)" \
 196             = "$quoted_svnrepo/added-symlink-file"
 197        '
 198
 199test_expect_success 'info added-symlink-directory' "
 200        (
 201                cd gitwc &&
 202                ln -s added-directory added-symlink-directory &&
 203                git add added-symlink-directory
 204        ) &&
 205        (
 206                cd svnwc &&
 207                ln -s added-directory added-symlink-directory &&
 208                svn_cmd add added-symlink-directory > /dev/null
 209        ) &&
 210        (cd svnwc; svn info added-symlink-directory) \
 211                > expected.info-added-symlink-directory &&
 212        (cd gitwc; git svn info added-symlink-directory) \
 213                > actual.info-added-symlink-directory &&
 214        test_cmp_info expected.info-added-symlink-directory \
 215                actual.info-added-symlink-directory
 216        "
 217
 218test_expect_success 'info --url added-symlink-directory' '
 219        test "$(cd gitwc; git svn info --url added-symlink-directory)" \
 220             = "$quoted_svnrepo/added-symlink-directory"
 221        '
 222
 223test_expect_success 'info deleted-file' "
 224        (
 225                cd gitwc &&
 226                git rm -f file > /dev/null
 227        ) &&
 228        (
 229                cd svnwc &&
 230                svn_cmd rm --force file > /dev/null
 231        ) &&
 232        (cd svnwc; svn info file) >expected.info-deleted-file &&
 233        (cd gitwc; git svn info file) >actual.info-deleted-file &&
 234        test_cmp_info expected.info-deleted-file actual.info-deleted-file
 235        "
 236
 237test_expect_success 'info --url file (deleted)' '
 238        test "$(cd gitwc; git svn info --url file)" \
 239             = "$quoted_svnrepo/file"
 240        '
 241
 242test_expect_success 'info deleted-directory' "
 243        (
 244                cd gitwc &&
 245                git rm -r -f directory > /dev/null
 246        ) &&
 247        (
 248                cd svnwc &&
 249                svn_cmd rm --force directory > /dev/null
 250        ) &&
 251        (cd svnwc; svn info directory) >expected.info-deleted-directory &&
 252        (cd gitwc; git svn info directory) >actual.info-deleted-directory &&
 253        test_cmp_info expected.info-deleted-directory actual.info-deleted-directory
 254        "
 255
 256test_expect_success 'info --url directory (deleted)' '
 257        test "$(cd gitwc; git svn info --url directory)" \
 258             = "$quoted_svnrepo/directory"
 259        '
 260
 261test_expect_success 'info deleted-symlink-file' "
 262        (
 263                cd gitwc &&
 264                git rm -f symlink-file > /dev/null
 265        ) &&
 266        (
 267                cd svnwc &&
 268                svn_cmd rm --force symlink-file > /dev/null
 269        ) &&
 270        (cd svnwc; svn info symlink-file) >expected.info-deleted-symlink-file &&
 271        (cd gitwc; git svn info symlink-file) >actual.info-deleted-symlink-file &&
 272        test_cmp_info expected.info-deleted-symlink-file actual.info-deleted-symlink-file
 273        "
 274
 275test_expect_success 'info --url symlink-file (deleted)' '
 276        test "$(cd gitwc; git svn info --url symlink-file)" \
 277             = "$quoted_svnrepo/symlink-file"
 278        '
 279
 280test_expect_success 'info deleted-symlink-directory' "
 281        (
 282                cd gitwc &&
 283                git rm -f symlink-directory > /dev/null
 284        ) &&
 285        (
 286                cd svnwc &&
 287                svn_cmd rm --force symlink-directory > /dev/null
 288        ) &&
 289        (cd svnwc; svn info symlink-directory) >expected.info-deleted-symlink-directory &&
 290        (cd gitwc; git svn info symlink-directory) >actual.info-deleted-symlink-directory &&
 291        test_cmp_info expected.info-deleted-symlink-directory actual.info-deleted-symlink-directory
 292        "
 293
 294test_expect_success 'info --url symlink-directory (deleted)' '
 295        test "$(cd gitwc; git svn info --url symlink-directory)" \
 296             = "$quoted_svnrepo/symlink-directory"
 297        '
 298
 299# NOTE: git does not have the concept of replaced objects,
 300# so we can't test for files in that state.
 301
 302test_expect_success 'info unknown-file' "
 303        echo two > gitwc/unknown-file &&
 304        (cd gitwc; test_must_fail git svn info unknown-file) \
 305                 2> actual.info-unknown-file &&
 306        grep unknown-file actual.info-unknown-file
 307        "
 308
 309test_expect_success 'info --url unknown-file' '
 310        echo two > gitwc/unknown-file &&
 311        (cd gitwc; test_must_fail git svn info --url unknown-file) \
 312                 2> actual.info-url-unknown-file &&
 313        grep unknown-file actual.info-url-unknown-file
 314        '
 315
 316test_expect_success 'info unknown-directory' "
 317        mkdir gitwc/unknown-directory svnwc/unknown-directory &&
 318        (cd gitwc; test_must_fail git svn info unknown-directory) \
 319                 2> actual.info-unknown-directory &&
 320        grep unknown-directory actual.info-unknown-directory
 321        "
 322
 323test_expect_success 'info --url unknown-directory' '
 324        (cd gitwc; test_must_fail git svn info --url unknown-directory) \
 325                 2> actual.info-url-unknown-directory &&
 326        grep unknown-directory actual.info-url-unknown-directory
 327        '
 328
 329test_expect_success 'info unknown-symlink-file' "
 330        (
 331                cd gitwc &&
 332                ln -s unknown-file unknown-symlink-file
 333        ) &&
 334        (cd gitwc; test_must_fail git svn info unknown-symlink-file) \
 335                 2> actual.info-unknown-symlink-file &&
 336        grep unknown-symlink-file actual.info-unknown-symlink-file
 337        "
 338
 339test_expect_success 'info --url unknown-symlink-file' '
 340        (cd gitwc; test_must_fail git svn info --url unknown-symlink-file) \
 341                 2> actual.info-url-unknown-symlink-file &&
 342        grep unknown-symlink-file actual.info-url-unknown-symlink-file
 343        '
 344
 345test_expect_success 'info unknown-symlink-directory' "
 346        (
 347                cd gitwc &&
 348                ln -s unknown-directory unknown-symlink-directory
 349        ) &&
 350        (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \
 351                 2> actual.info-unknown-symlink-directory &&
 352        grep unknown-symlink-directory actual.info-unknown-symlink-directory
 353        "
 354
 355test_expect_success 'info --url unknown-symlink-directory' '
 356        (cd gitwc; test_must_fail git svn info --url unknown-symlink-directory) \
 357                 2> actual.info-url-unknown-symlink-directory &&
 358        grep unknown-symlink-directory actual.info-url-unknown-symlink-directory
 359        '
 360
 361test_done