blob: aec45bca3b7b6fc4561e02ff975f77a5331cb7ce [file] [log] [blame]
Eric Wong45bf4732006-11-09 01:19:37 -08001#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09004test_description='git svn commit-diff clobber'
Eric Wong45bf4732006-11-09 01:19:37 -08005. ./lib-git-svn.sh
6
Bryan Donlanf69e8362008-05-04 01:37:59 -04007test_expect_success 'initialize repo' '
Eric Wong45bf4732006-11-09 01:19:37 -08008 mkdir import &&
Jonathan Nieder18a82692010-09-06 20:42:54 -05009 (
10 cd import &&
11 echo initial >file &&
12 svn_cmd import -m "initial" . "$svnrepo"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020013 ) &&
Eric Wong45bf4732006-11-09 01:19:37 -080014 echo initial > file &&
15 git update-index --add file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040016 git commit -a -m "initial"
17 '
18test_expect_success 'commit change from svn side' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040019 svn_cmd co "$svnrepo" t.svn &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050020 (
21 cd t.svn &&
22 echo second line from svn >>file &&
23 poke file &&
24 svn_cmd commit -m "second line from svn"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020025 ) &&
Eric Wong45bf4732006-11-09 01:19:37 -080026 rm -rf t.svn
Bryan Donlanf69e8362008-05-04 01:37:59 -040027 '
Eric Wong45bf4732006-11-09 01:19:37 -080028
Bryan Donlanf69e8362008-05-04 01:37:59 -040029test_expect_success 'commit conflicting change from git' '
Eric Wong45bf4732006-11-09 01:19:37 -080030 echo second line from git >> file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040031 git commit -a -m "second line from git" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090032 test_must_fail git svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
Bryan Donlanf69e8362008-05-04 01:37:59 -040033'
Eric Wong45bf4732006-11-09 01:19:37 -080034
Bryan Donlanf69e8362008-05-04 01:37:59 -040035test_expect_success 'commit complementing change from git' '
Eric Wong45bf4732006-11-09 01:19:37 -080036 git reset --hard HEAD~1 &&
37 echo second line from svn >> file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040038 git commit -a -m "second line from svn" &&
Eric Wong45bf4732006-11-09 01:19:37 -080039 echo third line from git >> file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040040 git commit -a -m "third line from git" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090041 git svn commit-diff -r2 HEAD~1 HEAD "$svnrepo"
Bryan Donlanf69e8362008-05-04 01:37:59 -040042 '
Eric Wong45bf4732006-11-09 01:19:37 -080043
Bryan Donlanf69e8362008-05-04 01:37:59 -040044test_expect_success 'dcommit fails to commit because of conflict' '
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090045 git svn init "$svnrepo" &&
46 git svn fetch &&
Jeff Kinge1c0c152016-05-13 16:47:14 -040047 git reset --hard refs/remotes/git-svn &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040048 svn_cmd co "$svnrepo" t.svn &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050049 (
50 cd t.svn &&
51 echo fourth line from svn >>file &&
52 poke file &&
53 svn_cmd commit -m "fourth line from svn"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020054 ) &&
Eric Wong45bf4732006-11-09 01:19:37 -080055 rm -rf t.svn &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040056 echo "fourth line from git" >> file &&
57 git commit -a -m "fourth line from git" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090058 test_must_fail git svn dcommit
Bryan Donlanf69e8362008-05-04 01:37:59 -040059 '
Eric Wong45bf4732006-11-09 01:19:37 -080060
61test_expect_success 'dcommit does the svn equivalent of an index merge' "
Jeff Kinge1c0c152016-05-13 16:47:14 -040062 git reset --hard refs/remotes/git-svn &&
Eric Wong45bf4732006-11-09 01:19:37 -080063 echo 'index merge' > file2 &&
64 git update-index --add file2 &&
65 git commit -a -m 'index merge' &&
66 echo 'more changes' >> file2 &&
67 git update-index file2 &&
68 git commit -a -m 'more changes' &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090069 git svn dcommit
Eric Wong45bf4732006-11-09 01:19:37 -080070 "
71
Bryan Donlanf69e8362008-05-04 01:37:59 -040072test_expect_success 'commit another change from svn side' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040073 svn_cmd co "$svnrepo" t.svn &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050074 (
75 cd t.svn &&
76 echo third line from svn >>file &&
Eric Wong751eb392007-08-31 18:16:12 -070077 poke file &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020078 svn_cmd commit -m "third line from svn"
79 ) &&
Eric Wong751eb392007-08-31 18:16:12 -070080 rm -rf t.svn
Bryan Donlanf69e8362008-05-04 01:37:59 -040081 '
Eric Wong751eb392007-08-31 18:16:12 -070082
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090083test_expect_success 'multiple dcommit from git svn will not clobber svn' "
Jeff Kinge1c0c152016-05-13 16:47:14 -040084 git reset --hard refs/remotes/git-svn &&
Eric Wong751eb392007-08-31 18:16:12 -070085 echo new file >> new-file &&
86 git update-index --add new-file &&
87 git commit -a -m 'new file' &&
88 echo clobber > file &&
89 git commit -a -m 'clobber' &&
Stephan Beyerd492b312008-07-12 17:47:52 +020090 test_must_fail git svn dcommit
Junio C Hamano41ac4142008-02-01 01:50:53 -080091 "
Eric Wong751eb392007-08-31 18:16:12 -070092
93
Johannes Schindelin51ef1da2008-07-21 12:51:02 +020094test_expect_success 'check that rebase really failed' '
Elijah Newren2ac0d622020-02-15 21:36:40 +000095 git status >output &&
96 grep currently.rebasing output
Johannes Schindelin51ef1da2008-07-21 12:51:02 +020097'
Eric Wong751eb392007-08-31 18:16:12 -070098
99test_expect_success 'resolve, continue the rebase and dcommit' "
100 echo clobber and I really mean it > file &&
101 git update-index file &&
102 git rebase --continue &&
103 git svn dcommit
104 "
105
Eric Wong45bf4732006-11-09 01:19:37 -0800106test_done