blob: e06538b1c854815c40aa43915d844089671cb2bd [file] [log] [blame]
Eric Wong733a65a2007-06-13 02:23:28 -07001#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
4# Based on a script by Joakim Tjernlund <joakim.tjernlund@transmode.se>
5
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09006test_description='git svn dcommit handles merges'
Eric Wong733a65a2007-06-13 02:23:28 -07007
8. ./lib-git-svn.sh
9
10big_text_block () {
11cat << 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
Josh Sorefd05b08c2023-11-24 03:35:13 +000030# along with this program; if not, see <https://www.gnu.org/licenses/>.
Eric Wong733a65a2007-06-13 02:23:28 -070031#
32EOF
33}
34
Bryan Donlanf69e8362008-05-04 01:37:59 -040035test_expect_success 'setup svn repository' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040036 svn_cmd co "$svnrepo" mysvnwork &&
Eric Wong733a65a2007-06-13 02:23:28 -070037 mkdir -p mysvnwork/trunk &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050038 (
39 cd mysvnwork &&
40 big_text_block >>trunk/README &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040041 svn_cmd add trunk &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020042 svn_cmd ci -m "first commit" trunk
Jonathan Nieder18a82692010-09-06 20:42:54 -050043 )
Bryan Donlanf69e8362008-05-04 01:37:59 -040044 '
Eric Wong733a65a2007-06-13 02:23:28 -070045
Bryan Donlanf69e8362008-05-04 01:37:59 -040046test_expect_success 'setup git mirror and merge' '
47 git svn init "$svnrepo" -t tags -T trunk -b branches &&
Eric Wong733a65a2007-06-13 02:23:28 -070048 git svn fetch &&
Johan Herlandfe191fc2013-10-11 14:57:07 +020049 git checkout -b svn remotes/origin/trunk &&
Eric Wong733a65a2007-06-13 02:23:28 -070050 git checkout -b merge &&
51 echo new file > new_file &&
52 git add new_file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040053 git commit -a -m "New file" &&
Eric Wong733a65a2007-06-13 02:23:28 -070054 echo hello >> README &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040055 git commit -a -m "hello" &&
Eric Wong733a65a2007-06-13 02:23:28 -070056 echo add some stuff >> new_file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040057 git commit -a -m "add some stuff" &&
Eric Wong733a65a2007-06-13 02:23:28 -070058 git checkout svn &&
59 mv -f README tmp &&
60 echo friend > README &&
61 cat tmp >> README &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040062 git commit -a -m "friend" &&
Felipe Contreras501a75a2013-10-31 03:25:33 -060063 git merge merge
Bryan Donlanf69e8362008-05-04 01:37:59 -040064 '
Eric Wong733a65a2007-06-13 02:23:28 -070065
66test_debug 'gitk --all & sleep 1'
67
68test_expect_success 'verify pre-merge ancestry' "
Elia Pinto78ba28d2016-01-12 10:45:17 +000069 test x\$(git rev-parse --verify refs/heads/svn^2) = \
70 x\$(git rev-parse --verify refs/heads/merge) &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054571 git cat-file commit refs/heads/svn^ >actual &&
72 grep '^friend$' actual
Eric Wong733a65a2007-06-13 02:23:28 -070073 "
74
75test_expect_success 'git svn dcommit merges' "
76 git svn dcommit
77 "
78
79test_debug 'gitk --all & sleep 1'
80
81test_expect_success 'verify post-merge ancestry' "
Elia Pinto78ba28d2016-01-12 10:45:17 +000082 test x\$(git rev-parse --verify refs/heads/svn) = \
83 x\$(git rev-parse --verify refs/remotes/origin/trunk) &&
84 test x\$(git rev-parse --verify refs/heads/svn^2) = \
85 x\$(git rev-parse --verify refs/heads/merge) &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054586 git cat-file commit refs/heads/svn^ >actual &&
87 grep '^friend$' actual
Eric Wong733a65a2007-06-13 02:23:28 -070088 "
89
Eric Wongfb159582007-11-05 03:21:48 -080090test_expect_success 'verify merge commit message' "
Pratik Karkia4d4e322018-03-27 23:16:37 +054591 git rev-list --pretty=raw -1 refs/heads/svn >actual &&
92 grep \" Merge branch 'merge' into svn\" actual
Eric Wongfb159582007-11-05 03:21:48 -080093 "
94
Eric Wong733a65a2007-06-13 02:23:28 -070095test_done