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