1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4test_description='git-svn commit-diff clobber'
5. ./lib-git-svn.sh
6
7test_expect_success 'initialize repo' "
8 mkdir import &&
9 cd import &&
10 echo initial > file &&
11 svn import -m 'initial' . $svnrepo &&
12 cd .. &&
13 echo initial > file &&
14 git update-index --add file &&
15 git commit -a -m 'initial'
16 "
17test_expect_success 'commit change from svn side' "
18 svn co $svnrepo t.svn &&
19 cd t.svn &&
20 echo second line from svn >> file &&
21 svn commit -m 'second line from svn' &&
22 cd .. &&
23 rm -rf t.svn
24 "
25
26test_expect_failure 'commit conflicting change from git' "
27 echo second line from git >> file &&
28 git commit -a -m 'second line from git' &&
29 git-svn commit-diff -r1 HEAD~1 HEAD $svnrepo
30 " || true
31
32test_expect_success 'commit complementing change from git' "
33 git reset --hard HEAD~1 &&
34 echo second line from svn >> file &&
35 git commit -a -m 'second line from svn' &&
36 echo third line from git >> file &&
37 git commit -a -m 'third line from git' &&
38 git-svn commit-diff -r2 HEAD~1 HEAD $svnrepo
39 "
40
41test_expect_failure 'dcommit fails to commit because of conflict' "
42 git-svn init $svnrepo &&
43 git-svn fetch &&
44 git reset --hard refs/remotes/git-svn &&
45 svn co $svnrepo t.svn &&
46 cd t.svn &&
47 echo fourth line from svn >> file &&
48 svn commit -m 'fourth line from svn' &&
49 cd .. &&
50 rm -rf t.svn &&
51 echo 'fourth line from git' >> file &&
52 git commit -a -m 'fourth line from git' &&
53 git-svn dcommit
54 " || true
55
56test_expect_success 'dcommit does the svn equivalent of an index merge' "
57 git reset --hard refs/remotes/git-svn &&
58 echo 'index merge' > file2 &&
59 git update-index --add file2 &&
60 git commit -a -m 'index merge' &&
61 echo 'more changes' >> file2 &&
62 git update-index file2 &&
63 git commit -a -m 'more changes' &&
64 git-svn dcommit
65 "
66
67test_done