t / t9109-git-svn-multi-glob.shon commit Merge branch 'js/mingw-http-ssl' (d7b1859)
   1#!/bin/sh
   2# Copyright (c) 2007 Eric Wong
   3test_description='git svn globbing refspecs'
   4. ./lib-git-svn.sh
   5
   6cat > expect.end <<EOF
   7the end
   8hi
   9start a new branch
  10initial
  11EOF
  12
  13test_expect_success 'test refspec globbing' '
  14        mkdir -p trunk/src/a trunk/src/b trunk/doc &&
  15        echo "hello world" > trunk/src/a/readme &&
  16        echo "goodbye world" > trunk/src/b/readme &&
  17        svn_cmd import -m "initial" trunk "$svnrepo"/trunk &&
  18        svn_cmd co "$svnrepo" tmp &&
  19        (
  20                cd tmp &&
  21                mkdir branches branches/v1 tags &&
  22                svn_cmd add branches tags &&
  23                svn_cmd cp trunk branches/v1/start &&
  24                svn_cmd commit -m "start a new branch" &&
  25                svn_cmd up &&
  26                echo "hi" >> branches/v1/start/src/b/readme &&
  27                poke branches/v1/start/src/b/readme &&
  28                echo "hey" >> branches/v1/start/src/a/readme &&
  29                poke branches/v1/start/src/a/readme &&
  30                svn_cmd commit -m "hi" &&
  31                svn_cmd up &&
  32                svn_cmd cp branches/v1/start tags/end &&
  33                echo "bye" >> tags/end/src/b/readme &&
  34                poke tags/end/src/b/readme &&
  35                echo "aye" >> tags/end/src/a/readme &&
  36                poke tags/end/src/a/readme &&
  37                svn_cmd commit -m "the end" &&
  38                echo "byebye" >> tags/end/src/b/readme &&
  39                poke tags/end/src/b/readme &&
  40                svn_cmd commit -m "nothing to see here"
  41        ) &&
  42        git config --add svn-remote.svn.url "$svnrepo" &&
  43        git config --add svn-remote.svn.fetch \
  44                         "trunk/src/a:refs/remotes/trunk" &&
  45        git config --add svn-remote.svn.branches \
  46                         "branches/*/*/src/a:refs/remotes/branches/*/*" &&
  47        git config --add svn-remote.svn.tags\
  48                         "tags/*/src/a:refs/remotes/tags/*" &&
  49        git svn multi-fetch &&
  50        git log --pretty=oneline refs/remotes/tags/end >actual &&
  51        sed -e "s/^.\{41\}//" actual >output.end &&
  52        test_cmp expect.end output.end &&
  53        test "$(git rev-parse refs/remotes/tags/end~1)" = \
  54                "$(git rev-parse refs/remotes/branches/v1/start)" &&
  55        test "$(git rev-parse refs/remotes/branches/v1/start~2)" = \
  56                "$(git rev-parse refs/remotes/trunk)" &&
  57        test_must_fail git rev-parse refs/remotes/tags/end@3
  58        '
  59
  60echo try to try > expect.two
  61echo nothing to see here >> expect.two
  62cat expect.end >> expect.two
  63
  64test_expect_success 'test left-hand-side only globbing' '
  65        git config --add svn-remote.two.url "$svnrepo" &&
  66        git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
  67        git config --add svn-remote.two.branches \
  68                         "branches/*/*:refs/remotes/two/branches/*/*" &&
  69        git config --add svn-remote.two.tags \
  70                         "tags/*:refs/remotes/two/tags/*" &&
  71        (
  72                cd tmp &&
  73                echo "try try" >> tags/end/src/b/readme &&
  74                poke tags/end/src/b/readme &&
  75                svn_cmd commit -m "try to try"
  76        ) &&
  77        git svn fetch two &&
  78        git rev-list refs/remotes/two/tags/end >actual &&
  79        test_line_count = 6 actual &&
  80        git rev-list refs/remotes/two/branches/v1/start >actual &&
  81        test_line_count = 3 actual &&
  82        test $(git rev-parse refs/remotes/two/branches/v1/start~2) = \
  83             $(git rev-parse refs/remotes/two/trunk) &&
  84        test $(git rev-parse refs/remotes/two/tags/end~3) = \
  85             $(git rev-parse refs/remotes/two/branches/v1/start) &&
  86        git log --pretty=oneline refs/remotes/two/tags/end >actual &&
  87        sed -e "s/^.\{41\}//" actual >output.two &&
  88        test_cmp expect.two output.two
  89        '
  90cat > expect.four <<EOF
  91adios
  92adding more
  93Changed 2 in v2/start
  94Another versioned branch
  95initial
  96EOF
  97
  98test_expect_success 'test another branch' '
  99        (
 100                cd tmp &&
 101                mkdir branches/v2 &&
 102                svn_cmd add branches/v2 &&
 103                svn_cmd cp trunk branches/v2/start &&
 104                svn_cmd commit -m "Another versioned branch" &&
 105                svn_cmd up &&
 106                echo "hello" >> branches/v2/start/src/b/readme &&
 107                poke branches/v2/start/src/b/readme &&
 108                echo "howdy" >> branches/v2/start/src/a/readme &&
 109                poke branches/v2/start/src/a/readme &&
 110                svn_cmd commit -m "Changed 2 in v2/start" &&
 111                svn_cmd up &&
 112                svn_cmd cp branches/v2/start tags/next &&
 113                echo "bye" >> tags/next/src/b/readme &&
 114                poke tags/next/src/b/readme &&
 115                echo "aye" >> tags/next/src/a/readme &&
 116                poke tags/next/src/a/readme &&
 117                svn_cmd commit -m "adding more" &&
 118                echo "byebye" >> tags/next/src/b/readme &&
 119                poke tags/next/src/b/readme &&
 120                svn_cmd commit -m "adios"
 121        ) &&
 122        git config --add svn-remote.four.url "$svnrepo" &&
 123        git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
 124        git config --add svn-remote.four.branches \
 125                         "branches/*/*:refs/remotes/four/branches/*/*" &&
 126        git config --add svn-remote.four.tags \
 127                         "tags/*:refs/remotes/four/tags/*" &&
 128        git svn fetch four &&
 129        git rev-list refs/remotes/four/tags/next >actual &&
 130        test_line_count = 5 actual &&
 131        git rev-list refs/remotes/four/branches/v2/start >actual &&
 132        test_line_count = 3 actual &&
 133        test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \
 134             $(git rev-parse refs/remotes/four/trunk) &&
 135        test $(git rev-parse refs/remotes/four/tags/next~2) = \
 136             $(git rev-parse refs/remotes/four/branches/v2/start) &&
 137        git log --pretty=oneline refs/remotes/four/tags/next >actual &&
 138        sed -e "s/^.\{41\}//" actual >output.four &&
 139        test_cmp expect.four output.four
 140        '
 141
 142test_expect_success 'prepare test disallow multiple globs' "
 143cat >expect.three <<EOF
 144Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
 145
 146EOF
 147        "
 148
 149test_expect_success 'test disallow multiple globs' '
 150        git config --add svn-remote.three.url "$svnrepo" &&
 151        git config --add svn-remote.three.fetch \
 152                         trunk:refs/remotes/three/trunk &&
 153        git config --add svn-remote.three.branches \
 154                         "branches/*/t/*:refs/remotes/three/branches/*/*" &&
 155        git config --add svn-remote.three.tags \
 156                         "tags/*:refs/remotes/three/tags/*" &&
 157        (
 158                cd tmp &&
 159                echo "try try" >> tags/end/src/b/readme &&
 160                poke tags/end/src/b/readme &&
 161                svn_cmd commit -m "try to try"
 162        ) &&
 163        test_must_fail git svn fetch three 2> stderr.three &&
 164        test_cmp expect.three stderr.three
 165        '
 166
 167test_done