Peter Baumann | 61b472e | 2012-08-09 08:42:53 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2012 Peter Baumann |
| 4 | # |
| 5 | |
| 6 | test_description='git svn reset clears memoized caches' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 7 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 8 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 9 | |
Peter Baumann | 61b472e | 2012-08-09 08:42:53 +0200 | [diff] [blame] | 10 | . ./lib-git-svn.sh |
| 11 | |
| 12 | svn_ver="$(svn --version --quiet)" |
| 13 | case $svn_ver in |
| 14 | 0.* | 1.[0-4].*) |
| 15 | skip_all="skipping git-svn test - SVN too old ($svn_ver)" |
| 16 | test_done |
| 17 | ;; |
| 18 | esac |
| 19 | |
| 20 | # ... a - b - m <- trunk |
| 21 | # \ / |
| 22 | # ... c <- branch1 |
| 23 | # |
| 24 | # SVN Commits not interesting for this test are abbreviated with "..." |
| 25 | # |
| 26 | test_expect_success 'initialize source svn repo' ' |
| 27 | svn_cmd mkdir -m "create trunk" "$svnrepo"/trunk && |
| 28 | svn_cmd mkdir -m "create branches" "$svnrepo/branches" && |
| 29 | svn_cmd co "$svnrepo"/trunk "$SVN_TREE" && |
| 30 | ( |
| 31 | cd "$SVN_TREE" && |
| 32 | touch foo && |
| 33 | svn_cmd add foo && |
| 34 | svn_cmd commit -m "a" && |
| 35 | svn_cmd cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 && |
| 36 | svn_cmd switch "$svnrepo"/branches/branch1 && |
| 37 | touch bar && |
| 38 | svn_cmd add bar && |
| 39 | svn_cmd commit -m b && |
| 40 | svn_cmd switch "$svnrepo"/trunk && |
| 41 | touch baz && |
| 42 | svn_cmd add baz && |
| 43 | svn_cmd commit -m c && |
| 44 | svn_cmd up && |
| 45 | svn_cmd merge "$svnrepo"/branches/branch1 && |
| 46 | svn_cmd commit -m "m" |
| 47 | ) && |
| 48 | rm -rf "$SVN_TREE" |
| 49 | ' |
| 50 | |
| 51 | test_expect_success 'fetch to merge-base (a)' ' |
| 52 | git svn init -s "$svnrepo" && |
| 53 | git svn fetch --revision BASE:3 |
| 54 | ' |
| 55 | |
| 56 | # git svn rebase looses the merge commit |
| 57 | # |
| 58 | # ... a - b - m <- trunk |
| 59 | # \ |
| 60 | # ... c |
| 61 | # |
| 62 | test_expect_success 'rebase looses SVN merge (m)' ' |
| 63 | git svn rebase && |
| 64 | git svn fetch && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 65 | test 1 = $(git cat-file -p main|grep parent|wc -l) |
Peter Baumann | 61b472e | 2012-08-09 08:42:53 +0200 | [diff] [blame] | 66 | ' |
| 67 | |
| 68 | # git svn fetch creates correct history with merge commit |
| 69 | # |
| 70 | # ... a - b - m <- trunk |
| 71 | # \ / |
| 72 | # ... c <- branch1 |
| 73 | # |
| 74 | test_expect_success 'reset and fetch gets the SVN merge (m) correctly' ' |
| 75 | git svn reset -r 3 && |
Johan Herland | fe191fc | 2013-10-11 14:57:07 +0200 | [diff] [blame] | 76 | git reset --hard origin/trunk && |
Peter Baumann | 61b472e | 2012-08-09 08:42:53 +0200 | [diff] [blame] | 77 | git svn fetch && |
Johan Herland | fe191fc | 2013-10-11 14:57:07 +0200 | [diff] [blame] | 78 | test 2 = $(git cat-file -p origin/trunk|grep parent|wc -l) |
Peter Baumann | 61b472e | 2012-08-09 08:42:53 +0200 | [diff] [blame] | 79 | ' |
| 80 | |
| 81 | test_done |