contrib / git-svn / t / t0000-contrib-git-svn.shon commit Up to date with GIT 1.2.4 fixes (2495ca0)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Eric Wong
   4#
   5
   6
   7PATH=$PWD/../:$PATH
   8test_description='git-svn tests'
   9if test -d ../../../t
  10then
  11    cd ../../../t
  12else
  13    echo "Must be run in contrib/git-svn/t" >&2
  14    exit 1
  15fi
  16
  17. ./test-lib.sh
  18
  19GIT_DIR=$PWD/.git
  20GIT_SVN_DIR=$GIT_DIR/git-svn
  21SVN_TREE=$GIT_SVN_DIR/tree
  22
  23svnadmin >/dev/null 2>&1
  24if test $? != 1
  25then
  26    test_expect_success 'skipping contrib/git-svn test' :
  27    test_done
  28    exit
  29fi
  30
  31svn >/dev/null 2>&1
  32if test $? != 1
  33then
  34    test_expect_success 'skipping contrib/git-svn test' :
  35    test_done
  36    exit
  37fi
  38
  39svnrepo=$PWD/svnrepo
  40
  41set -e
  42
  43svnadmin create $svnrepo
  44svnrepo="file://$svnrepo/test-git-svn"
  45
  46mkdir import
  47
  48cd import
  49
  50echo foo > foo
  51ln -s foo foo.link
  52mkdir -p dir/a/b/c/d/e
  53echo 'deep dir' > dir/a/b/c/d/e/file
  54mkdir -p bar
  55echo 'zzz' > bar/zzz
  56echo '#!/bin/sh' > exec.sh
  57chmod +x exec.sh
  58svn import -m 'import for git-svn' . $svnrepo >/dev/null
  59
  60cd ..
  61
  62rm -rf import
  63
  64test_expect_success \
  65    'initialize git-svn' \
  66    "git-svn init $svnrepo"
  67
  68test_expect_success \
  69    'import an SVN revision into git' \
  70    'git-svn fetch'
  71
  72
  73name='try a deep --rmdir with a commit'
  74git checkout -b mybranch git-svn-HEAD
  75mv dir/a/b/c/d/e/file dir/file
  76cp dir/file file
  77git update-index --add --remove dir/a/b/c/d/e/file dir/file file
  78git commit -m "$name"
  79
  80test_expect_success "$name" \
  81    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch &&
  82     test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
  83
  84
  85name='detect node change from file to directory #1'
  86mkdir dir/new_file
  87mv dir/file dir/new_file/file
  88mv dir/new_file dir/file
  89git update-index --remove dir/file
  90git update-index --add dir/file/file
  91git commit -m "$name"
  92
  93test_expect_code 1 "$name" \
  94    'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch' \
  95    || true
  96
  97
  98name='detect node change from directory to file #1'
  99rm -rf dir $GIT_DIR/index
 100git checkout -b mybranch2 git-svn-HEAD
 101mv bar/zzz zzz
 102rm -rf bar
 103mv zzz bar
 104git update-index --remove -- bar/zzz
 105git update-index --add -- bar
 106git commit -m "$name"
 107
 108test_expect_code 1 "$name" \
 109    'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch2' \
 110    || true
 111
 112
 113name='detect node change from file to directory #2'
 114rm -f $GIT_DIR/index
 115git checkout -b mybranch3 git-svn-HEAD
 116rm bar/zzz
 117git-update-index --remove bar/zzz
 118mkdir bar/zzz
 119echo yyy > bar/zzz/yyy
 120git-update-index --add bar/zzz/yyy
 121git commit -m "$name"
 122
 123test_expect_code 1 "$name" \
 124    'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch3' \
 125    || true
 126
 127
 128name='detect node change from directory to file #2'
 129rm -f $GIT_DIR/index
 130git checkout -b mybranch4 git-svn-HEAD
 131rm -rf dir
 132git update-index --remove -- dir/file
 133touch dir
 134echo asdf > dir
 135git update-index --add -- dir
 136git commit -m "$name"
 137
 138test_expect_code 1 "$name" \
 139    'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch4' \
 140    || true
 141
 142
 143name='remove executable bit from a file'
 144rm -f $GIT_DIR/index
 145git checkout -b mybranch5 git-svn-HEAD
 146chmod -x exec.sh
 147git update-index exec.sh
 148git commit -m "$name"
 149
 150test_expect_success "$name" \
 151    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
 152     test ! -x $SVN_TREE/exec.sh"
 153
 154
 155name='add executable bit back file'
 156chmod +x exec.sh
 157git update-index exec.sh
 158git commit -m "$name"
 159
 160test_expect_success "$name" \
 161    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
 162     test -x $SVN_TREE/exec.sh"
 163
 164
 165
 166name='executable file becomes a symlink to bar/zzz (file)'
 167rm exec.sh
 168ln -s bar/zzz exec.sh
 169git update-index exec.sh
 170git commit -m "$name"
 171
 172test_expect_success "$name" \
 173    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
 174     test -L $SVN_TREE/exec.sh"
 175
 176
 177
 178name='new symlink is added to a file that was also just made executable'
 179chmod +x bar/zzz
 180ln -s bar/zzz exec-2.sh
 181git update-index --add bar/zzz exec-2.sh
 182git commit -m "$name"
 183
 184test_expect_success "$name" \
 185    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
 186     test -x $SVN_TREE/bar/zzz &&
 187     test -L $SVN_TREE/exec-2.sh"
 188
 189
 190
 191name='modify a symlink to become a file'
 192git help > help || true
 193rm exec-2.sh
 194cp help exec-2.sh
 195git update-index exec-2.sh
 196git commit -m "$name"
 197
 198test_expect_success "$name" \
 199    "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
 200     test -f $SVN_TREE/exec-2.sh &&
 201     test ! -L $SVN_TREE/exec-2.sh &&
 202     diff -u help $SVN_TREE/exec-2.sh"
 203
 204
 205
 206name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
 207GIT_SVN_ID=alt
 208export GIT_SVN_ID
 209test_expect_success "$name" \
 210    "git-svn init $svnrepo && git-svn fetch -v &&
 211     git-rev-list --pretty=raw git-svn-HEAD | grep ^tree | uniq > a &&
 212     git-rev-list --pretty=raw alt-HEAD | grep ^tree | uniq > b &&
 213     diff -u a b"
 214
 215test_done
 216