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