1#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
4# Based on a script by Joakim Tjernlund <joakim.tjernlund@transmode.se>
56
test_description='git svn dcommit handles merges'
78
. ./lib-git-svn.sh
910
big_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
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#
34EOF
35}
3637
test_expect_success 'setup svn repository' '
38svn_cmd co "$svnrepo" mysvnwork &&
39mkdir -p mysvnwork/trunk &&
40(cd mysvnwork &&
41big_text_block >> trunk/README &&
42svn_cmd add trunk &&
43svn_cmd ci -m "first commit" trunk
44)
45'
4647
test_expect_success 'setup git mirror and merge' '
48git svn init "$svnrepo" -t tags -T trunk -b branches &&
49git svn fetch &&
50git checkout --track -b svn remotes/trunk &&
51git checkout -b merge &&
52echo new file > new_file &&
53git add new_file &&
54git commit -a -m "New file" &&
55echo hello >> README &&
56git commit -a -m "hello" &&
57echo add some stuff >> new_file &&
58git commit -a -m "add some stuff" &&
59git checkout svn &&
60mv -f README tmp &&
61echo friend > README &&
62cat tmp >> README &&
63git commit -a -m "friend" &&
64git pull . merge
65'
6667
test_debug 'gitk --all & sleep 1'
6869
test_expect_success 'verify pre-merge ancestry' "
70test x\`git rev-parse --verify refs/heads/svn^2\` = \
71x\`git rev-parse --verify refs/heads/merge\` &&
72git cat-file commit refs/heads/svn^ | grep '^friend$'
73"
7475
test_expect_success 'git svn dcommit merges' "
76git svn dcommit
77"
7879
test_debug 'gitk --all & sleep 1'
8081
test_expect_success 'verify post-merge ancestry' "
82test x\`git rev-parse --verify refs/heads/svn\` = \
83x\`git rev-parse --verify refs/remotes/trunk \` &&
84test x\`git rev-parse --verify refs/heads/svn^2\` = \
85x\`git rev-parse --verify refs/heads/merge\` &&
86git cat-file commit refs/heads/svn^ | grep '^friend$'
87"
8889
test_expect_success 'verify merge commit message' "
90git rev-list --pretty=raw -1 refs/heads/svn | \
91grep \" Merge branch 'merge' into svn\"
92"
9394
test_done