Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Eric Wong |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 4 | test_description='git svn dcommit clobber series' |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 5 | . ./lib-git-svn.sh |
| 6 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 7 | test_expect_success 'initialize repo' ' |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 8 | mkdir import && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 9 | (cd import && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 10 | awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 11 | svn_cmd import -m "initial" . "$svnrepo" |
| 12 | ) && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 13 | git svn init "$svnrepo" && |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 14 | git svn fetch && |
| 15 | test -e file |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 16 | ' |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 17 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 18 | test_expect_success '(supposedly) non-conflicting change from SVN' ' |
Elia Pinto | 2525c51 | 2016-01-12 11:49:31 +0000 | [diff] [blame] | 19 | test x"$(sed -n -e 58p < file)" = x58 && |
| 20 | test x"$(sed -n -e 61p < file)" = x61 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 21 | svn_cmd co "$svnrepo" tmp && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 22 | (cd tmp && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 23 | perl -i.bak -p -e "s/^58$/5588/" file && |
| 24 | perl -i.bak -p -e "s/^61$/6611/" file && |
Eric Wong | 8d92f24 | 2007-11-21 00:57:33 -0800 | [diff] [blame] | 25 | poke file && |
Elia Pinto | 2525c51 | 2016-01-12 11:49:31 +0000 | [diff] [blame] | 26 | test x"$(sed -n -e 58p < file)" = x5588 && |
| 27 | test x"$(sed -n -e 61p < file)" = x6611 && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 28 | svn_cmd commit -m "58 => 5588, 61 => 6611" |
| 29 | ) |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 30 | ' |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 31 | |
| 32 | test_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 | |
| 40 | test_expect_success 'change file but in unrelated area' " |
Elia Pinto | 2525c51 | 2016-01-12 11:49:31 +0000 | [diff] [blame] | 41 | test x\"\$(sed -n -e 4p < file)\" = x4 && |
| 42 | test x\"\$(sed -n -e 7p < file)\" = x7 && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 43 | perl -i.bak -p -e 's/^4\$/4444/' file && |
| 44 | perl -i.bak -p -e 's/^7\$/7777/' file && |
Elia Pinto | 2525c51 | 2016-01-12 11:49:31 +0000 | [diff] [blame] | 45 | test x\"\$(sed -n -e 4p < file)\" = x4444 && |
| 46 | test x\"\$(sed -n -e 7p < file)\" = x7777 && |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 47 | git commit -m '4 => 4444, 7 => 7777' file && |
| 48 | git svn dcommit && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 49 | svn_cmd up tmp && |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 50 | cd tmp && |
Elia Pinto | 2525c51 | 2016-01-12 11:49:31 +0000 | [diff] [blame] | 51 | 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 Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 55 | " |
| 56 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 57 | test_expect_success 'attempt to dcommit with a dirty index' ' |
Benoit Sigoure | c8cfa3e | 2007-11-11 19:41:41 +0100 | [diff] [blame] | 58 | echo foo >>file && |
| 59 | git add file && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 60 | test_must_fail git svn dcommit |
Benoit Sigoure | c8cfa3e | 2007-11-11 19:41:41 +0100 | [diff] [blame] | 61 | ' |
| 62 | |
Eric Wong | c74d9ac | 2007-11-05 03:21:47 -0800 | [diff] [blame] | 63 | test_done |