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