Code

Merge branch 'jn/maint-do-not-match-with-unsanitized-searchtext' into maint
[git.git] / t / t9100-git-svn-basic.sh
index 4eee2e9fa6bacdc0d130a692f727885c5fa42e49..b041516a1d6316dd36657b582c15100c0a7359d0 100755 (executable)
@@ -15,24 +15,25 @@ case "$GIT_SVN_LC_ALL" in
        test_set_prereq UTF8
        ;;
 *)
-       say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)"
+       say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)"
        ;;
 esac
 
 test_expect_success \
     'initialize git svn' '
        mkdir import &&
-       cd import &&
-       echo foo > foo &&
-       ln -s foo foo.link
-       mkdir -p dir/a/b/c/d/e &&
-       echo "deep dir" > dir/a/b/c/d/e/file &&
-       mkdir bar &&
-       echo "zzz" > bar/zzz &&
-       echo "#!/bin/sh" > exec.sh &&
-       chmod +x exec.sh &&
-       svn import -m "import for git svn" . "$svnrepo" >/dev/null &&
-       cd .. &&
+       (
+               cd import &&
+               echo foo >foo &&
+               ln -s foo foo.link
+               mkdir -p dir/a/b/c/d/e &&
+               echo "deep dir" >dir/a/b/c/d/e/file &&
+               mkdir bar &&
+               echo "zzz" >bar/zzz &&
+               echo "#!/bin/sh" >exec.sh &&
+               chmod +x exec.sh &&
+               svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null
+       ) &&
        rm -rf import &&
        git svn init "$svnrepo"'
 
@@ -51,7 +52,7 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch &&
-       svn up "$SVN_TREE" &&
+       svn_cmd up "$SVN_TREE" &&
        test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a'
 
 
@@ -118,7 +119,7 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch5 &&
-       svn up "$SVN_TREE" &&
+       svn_cmd up "$SVN_TREE" &&
        test ! -x "$SVN_TREE"/exec.sh'
 
 
@@ -129,7 +130,7 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch5 &&
-       svn up "$SVN_TREE" &&
+       svn_cmd up "$SVN_TREE" &&
        test -x "$SVN_TREE"/exec.sh'
 
 
@@ -141,8 +142,8 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch5 &&
-       svn up "$SVN_TREE" &&
-       test -L "$SVN_TREE"/exec.sh'
+       svn_cmd up "$SVN_TREE" &&
+       test -h "$SVN_TREE"/exec.sh'
 
 name='new symlink is added to a file that was also just made executable'
 
@@ -153,9 +154,9 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch5 &&
-       svn up "$SVN_TREE" &&
+       svn_cmd up "$SVN_TREE" &&
        test -x "$SVN_TREE"/bar/zzz &&
-       test -L "$SVN_TREE"/exec-2.sh'
+       test -h "$SVN_TREE"/exec-2.sh'
 
 name='modify a symlink to become a file'
 test_expect_success "$name" '
@@ -166,9 +167,9 @@ test_expect_success "$name" '
        git commit -m "$name" &&
        git svn set-tree --find-copies-harder --rmdir \
                ${remotes_git_svn}..mybranch5 &&
-       svn up "$SVN_TREE" &&
+       svn_cmd up "$SVN_TREE" &&
        test -f "$SVN_TREE"/exec-2.sh &&
-       test ! -L "$SVN_TREE"/exec-2.sh &&
+       test ! -h "$SVN_TREE"/exec-2.sh &&
        test_cmp help "$SVN_TREE"/exec-2.sh'
 
 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
@@ -231,6 +232,25 @@ test_expect_success \
                               "^:refs/${remotes_git_svn}$"
         '
 
+test_expect_success 'dcommit $rev does not clobber current branch' '
+       git svn fetch -i bar &&
+       git checkout -b my-bar refs/remotes/bar &&
+       echo 1 > foo &&
+       git add foo &&
+       git commit -m "change 1" &&
+       echo 2 > foo &&
+       git add foo &&
+       git commit -m "change 2" &&
+       old_head=$(git rev-parse HEAD) &&
+       git svn dcommit -i bar HEAD^ &&
+       test $old_head = $(git rev-parse HEAD) &&
+       test refs/heads/my-bar = $(git symbolic-ref HEAD) &&
+       git log refs/remotes/bar | grep "change 1" &&
+       ! git log refs/remotes/bar | grep "change 2" &&
+       git checkout master &&
+       git branch -D my-bar
+       '
+
 test_expect_success 'able to dcommit to a subdirectory' "
        git svn fetch -i bar &&
        git checkout -b my-bar refs/remotes/bar &&
@@ -252,6 +272,17 @@ test_expect_success 'able to dcommit to a subdirectory' "
        test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\"
        "
 
+test_expect_success 'dcommit should not fail with a touched file' '
+       test_commit "commit-new-file-foo2" foo2 &&
+       test-chmtime =-60 foo &&
+       git svn dcommit
+'
+
+test_expect_success 'rebase should not fail with a touched file' '
+       test-chmtime =-60 foo &&
+       git svn rebase
+'
+
 test_expect_success 'able to set-tree to a subdirectory' "
        echo cba > d &&
        git update-index d &&