Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Eric Wong |
| 4 | # Based on a script by Joakim Tjernlund <joakim.tjernlund@transmode.se> |
| 5 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 6 | test_description='git svn dcommit handles merges' |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 7 | |
| 8 | . ./lib-git-svn.sh |
| 9 | |
| 10 | big_text_block () { |
| 11 | cat << EOF |
| 12 | # |
| 13 | # (C) Copyright 2000 - 2005 |
| 14 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 15 | # |
| 16 | # See file CREDITS for list of people who contributed to this |
| 17 | # project. |
| 18 | # |
| 19 | # This program is free software; you can redistribute it and/or |
| 20 | # modify it under the terms of the GNU General Public License as |
| 21 | # published by the Free Software Foundation; either version 2 of |
| 22 | # the License, or (at your option) any later version. |
| 23 | # |
| 24 | # This program is distributed in the hope that it will be useful, |
| 25 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | # GNU General Public License for more details. |
| 28 | # |
| 29 | # You should have received a copy of the GNU General Public License |
| 30 | # along with this program; if not, write to the Free Software |
| 31 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 32 | # MA 02111-1307 USA |
| 33 | # |
| 34 | EOF |
| 35 | } |
| 36 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 37 | test_expect_success 'setup svn repository' ' |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 38 | svn_cmd co "$svnrepo" mysvnwork && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 39 | mkdir -p mysvnwork/trunk && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 40 | ( |
| 41 | cd mysvnwork && |
| 42 | big_text_block >>trunk/README && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 43 | svn_cmd add trunk && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 44 | svn_cmd ci -m "first commit" trunk |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 45 | ) |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 46 | ' |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 47 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 48 | test_expect_success 'setup git mirror and merge' ' |
| 49 | git svn init "$svnrepo" -t tags -T trunk -b branches && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 50 | git svn fetch && |
Johan Herland | fe191fc | 2013-10-11 14:57:07 +0200 | [diff] [blame] | 51 | git checkout -b svn remotes/origin/trunk && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 52 | git checkout -b merge && |
| 53 | echo new file > new_file && |
| 54 | git add new_file && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 55 | git commit -a -m "New file" && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 56 | echo hello >> README && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 57 | git commit -a -m "hello" && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 58 | echo add some stuff >> new_file && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 59 | git commit -a -m "add some stuff" && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 60 | git checkout svn && |
| 61 | mv -f README tmp && |
| 62 | echo friend > README && |
| 63 | cat tmp >> README && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 64 | git commit -a -m "friend" && |
Felipe Contreras | 501a75a | 2013-10-31 03:25:33 -0600 | [diff] [blame] | 65 | git merge merge |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 66 | ' |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 67 | |
| 68 | test_debug 'gitk --all & sleep 1' |
| 69 | |
| 70 | test_expect_success 'verify pre-merge ancestry' " |
Elia Pinto | 78ba28d | 2016-01-12 10:45:17 +0000 | [diff] [blame] | 71 | test x\$(git rev-parse --verify refs/heads/svn^2) = \ |
| 72 | x\$(git rev-parse --verify refs/heads/merge) && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 73 | git cat-file commit refs/heads/svn^ | grep '^friend$' |
| 74 | " |
| 75 | |
| 76 | test_expect_success 'git svn dcommit merges' " |
| 77 | git svn dcommit |
| 78 | " |
| 79 | |
| 80 | test_debug 'gitk --all & sleep 1' |
| 81 | |
| 82 | test_expect_success 'verify post-merge ancestry' " |
Elia Pinto | 78ba28d | 2016-01-12 10:45:17 +0000 | [diff] [blame] | 83 | test x\$(git rev-parse --verify refs/heads/svn) = \ |
| 84 | x\$(git rev-parse --verify refs/remotes/origin/trunk) && |
| 85 | test x\$(git rev-parse --verify refs/heads/svn^2) = \ |
| 86 | x\$(git rev-parse --verify refs/heads/merge) && |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 87 | git cat-file commit refs/heads/svn^ | grep '^friend$' |
| 88 | " |
| 89 | |
Eric Wong | fb15958 | 2007-11-05 03:21:48 -0800 | [diff] [blame] | 90 | test_expect_success 'verify merge commit message' " |
| 91 | git rev-list --pretty=raw -1 refs/heads/svn | \ |
| 92 | grep \" Merge branch 'merge' into svn\" |
| 93 | " |
| 94 | |
Eric Wong | 733a65a | 2007-06-13 02:23:28 -0700 | [diff] [blame] | 95 | test_done |