t / t9107-git-svn-migrate.shon commit Merge branch 'jc/maint-branch-mergeoptions' into mg/merge-ff-config (541d1fa)
   1#!/bin/sh
   2# Copyright (c) 2006 Eric Wong
   3test_description='git svn metadata migrations from previous versions'
   4. ./lib-git-svn.sh
   5
   6test_expect_success 'setup old-looking metadata' '
   7        cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
   8        mkdir import &&
   9        (
  10                cd import &&
  11                for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
  12                do
  13                        mkdir -p $i &&
  14                        echo hello >>$i/README ||
  15                        exit 1
  16                done &&
  17                svn_cmd import -m test . "$svnrepo"
  18        ) &&
  19        git svn init "$svnrepo" &&
  20        git svn fetch &&
  21        rm -rf "$GIT_DIR"/svn &&
  22        git update-ref refs/heads/git-svn-HEAD refs/${remotes_git_svn} &&
  23        git update-ref refs/heads/svn-HEAD refs/${remotes_git_svn} &&
  24        git update-ref -d refs/${remotes_git_svn} refs/${remotes_git_svn}
  25        '
  26
  27head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
  28test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
  29
  30test_expect_success 'initialize old-style (v0) git svn layout' '
  31        mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info &&
  32        echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url &&
  33        echo "$svnrepo" > "$GIT_DIR"/svn/info/url &&
  34        git svn migrate &&
  35        ! test -d "$GIT_DIR"/git svn &&
  36        git rev-parse --verify refs/${remotes_git_svn}^0 &&
  37        git rev-parse --verify refs/remotes/svn^0 &&
  38        test "$(git config --get svn-remote.svn.url)" = "$svnrepo" &&
  39        test `git config --get svn-remote.svn.fetch` = \
  40             ":refs/${remotes_git_svn}"
  41        '
  42
  43test_expect_success 'initialize a multi-repository repo' '
  44        git svn init "$svnrepo" -T trunk -t tags -b branches &&
  45        git config --get-all svn-remote.svn.fetch > fetch.out &&
  46        grep "^trunk:refs/remotes/trunk$" fetch.out &&
  47        test -n "`git config --get svn-remote.svn.branches \
  48                    "^branches/\*:refs/remotes/\*$"`" &&
  49        test -n "`git config --get svn-remote.svn.tags \
  50                    "^tags/\*:refs/remotes/tags/\*$"`" &&
  51        git config --unset svn-remote.svn.branches \
  52                                "^branches/\*:refs/remotes/\*$" &&
  53        git config --unset svn-remote.svn.tags \
  54                                "^tags/\*:refs/remotes/tags/\*$" &&
  55        git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
  56        git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
  57        for i in tags/0.1 tags/0.2 tags/0.3; do
  58                git config --add svn-remote.svn.fetch \
  59                                 $i:refs/remotes/$i || exit 1; done &&
  60        git config --get-all svn-remote.svn.fetch > fetch.out &&
  61        grep "^trunk:refs/remotes/trunk$" fetch.out &&
  62        grep "^branches/a:refs/remotes/a$" fetch.out &&
  63        grep "^branches/b:refs/remotes/b$" fetch.out &&
  64        grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
  65        grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
  66        grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
  67        grep "^:refs/${remotes_git_svn}" fetch.out
  68        '
  69
  70# refs should all be different, but the trees should all be the same:
  71test_expect_success 'multi-fetch works on partial urls + paths' "
  72        git svn multi-fetch &&
  73        for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
  74                git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
  75            done &&
  76        test -z \"\`sort < refs.out | uniq -d\`\" &&
  77        for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
  78          for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
  79                if test \$j != \$i; then continue; fi
  80            test -z \"\`git diff refs/remotes/\$i \
  81                                 refs/remotes/\$j\`\" ||exit 1; done; done
  82        "
  83
  84test_expect_success 'migrate --minimize on old inited layout' '
  85        git config --unset-all svn-remote.svn.fetch &&
  86        git config --unset-all svn-remote.svn.url &&
  87        rm -rf "$GIT_DIR"/svn &&
  88        for i in `cat fetch.out`; do
  89                path=`expr $i : "\([^:]*\):.*$"`
  90                ref=`expr $i : "[^:]*:\(refs/remotes/.*\)$"`
  91                if test -z "$ref"; then continue; fi
  92                if test -n "$path"; then path="/$path"; fi
  93                ( mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
  94                echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
  95        done &&
  96        git svn migrate --minimize &&
  97        test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
  98        git config --get-all svn-remote.svn.fetch > fetch.out &&
  99        grep "^trunk:refs/remotes/trunk$" fetch.out &&
 100        grep "^branches/a:refs/remotes/a$" fetch.out &&
 101        grep "^branches/b:refs/remotes/b$" fetch.out &&
 102        grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
 103        grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
 104        grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
 105        grep "^:refs/${remotes_git_svn}" fetch.out
 106        '
 107
 108test_expect_success  ".rev_db auto-converted to .rev_map.UUID" '
 109        git svn fetch -i trunk &&
 110        test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
 111        expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
 112        test -n "$expect" &&
 113        rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
 114        convert_to_rev_db "$expect" "$rev_db" &&
 115        rm -f "$expect" &&
 116        test -f "$rev_db" &&
 117        git svn fetch -i trunk &&
 118        test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
 119        test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
 120        test -f "$expect"
 121        '
 122
 123test_done