blob: 5fa07a369ff06f739a9edea2a8924fc3f19a88ca [file] [log] [blame]
Eric Wongc74d9ac2007-11-05 03:21:47 -08001#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09004test_description='git svn dcommit clobber series'
Eric Wongc74d9ac2007-11-05 03:21:47 -08005. ./lib-git-svn.sh
6
Bryan Donlanf69e8362008-05-04 01:37:59 -04007test_expect_success 'initialize repo' '
Eric Wongc74d9ac2007-11-05 03:21:47 -08008 mkdir import &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +02009 (cd import &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040010 awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020011 svn_cmd import -m "initial" . "$svnrepo"
12 ) &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040013 git svn init "$svnrepo" &&
Eric Wongc74d9ac2007-11-05 03:21:47 -080014 git svn fetch &&
15 test -e file
Bryan Donlanf69e8362008-05-04 01:37:59 -040016 '
Eric Wongc74d9ac2007-11-05 03:21:47 -080017
Bryan Donlanf69e8362008-05-04 01:37:59 -040018test_expect_success '(supposedly) non-conflicting change from SVN' '
Elia Pinto2525c512016-01-12 11:49:31 +000019 test x"$(sed -n -e 58p < file)" = x58 &&
20 test x"$(sed -n -e 61p < file)" = x61 &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040021 svn_cmd co "$svnrepo" tmp &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020022 (cd tmp &&
Jeff King94221d22013-10-28 21:23:03 -040023 perl -i.bak -p -e "s/^58$/5588/" file &&
24 perl -i.bak -p -e "s/^61$/6611/" file &&
Eric Wong8d92f242007-11-21 00:57:33 -080025 poke file &&
Elia Pinto2525c512016-01-12 11:49:31 +000026 test x"$(sed -n -e 58p < file)" = x5588 &&
27 test x"$(sed -n -e 61p < file)" = x6611 &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020028 svn_cmd commit -m "58 => 5588, 61 => 6611"
29 )
Bryan Donlanf69e8362008-05-04 01:37:59 -040030 '
Eric Wongc74d9ac2007-11-05 03:21:47 -080031
32test_expect_success 'some unrelated changes to git' "
33 echo hi > life &&
34 git update-index --add life &&
35 git commit -m hi-life &&
36 echo bye >> life &&
37 git commit -m bye-life life
38 "
39
40test_expect_success 'change file but in unrelated area' "
Elia Pinto2525c512016-01-12 11:49:31 +000041 test x\"\$(sed -n -e 4p < file)\" = x4 &&
42 test x\"\$(sed -n -e 7p < file)\" = x7 &&
Jeff King94221d22013-10-28 21:23:03 -040043 perl -i.bak -p -e 's/^4\$/4444/' file &&
44 perl -i.bak -p -e 's/^7\$/7777/' file &&
Elia Pinto2525c512016-01-12 11:49:31 +000045 test x\"\$(sed -n -e 4p < file)\" = x4444 &&
46 test x\"\$(sed -n -e 7p < file)\" = x7777 &&
Eric Wongc74d9ac2007-11-05 03:21:47 -080047 git commit -m '4 => 4444, 7 => 7777' file &&
48 git svn dcommit &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040049 svn_cmd up tmp &&
Eric Wongc74d9ac2007-11-05 03:21:47 -080050 cd tmp &&
Elia Pinto2525c512016-01-12 11:49:31 +000051 test x\"\$(sed -n -e 4p < file)\" = x4444 &&
52 test x\"\$(sed -n -e 7p < file)\" = x7777 &&
53 test x\"\$(sed -n -e 58p < file)\" = x5588 &&
54 test x\"\$(sed -n -e 61p < file)\" = x6611
Eric Wongc74d9ac2007-11-05 03:21:47 -080055 "
56
Junio C Hamano41ac4142008-02-01 01:50:53 -080057test_expect_success 'attempt to dcommit with a dirty index' '
Benoit Sigourec8cfa3e2007-11-11 19:41:41 +010058 echo foo >>file &&
59 git add file &&
Stephan Beyerd492b312008-07-12 17:47:52 +020060 test_must_fail git svn dcommit
Benoit Sigourec8cfa3e2007-11-11 19:41:41 +010061'
62
Eric Wongc74d9ac2007-11-05 03:21:47 -080063test_done