blob: 978eb62ff4fa9c059c0c0bbcbb4b510e1bc7b6d4 [file] [log] [blame]
Peter Baumann61b472e2012-08-09 08:42:53 +02001#!/bin/sh
2#
3# Copyright (c) 2012 Peter Baumann
4#
5
6test_description='git svn reset clears memoized caches'
Johannes Schindelina881baa2020-11-18 23:44:42 +00007GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +00008export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
Peter Baumann61b472e2012-08-09 08:42:53 +020010. ./lib-git-svn.sh
11
12svn_ver="$(svn --version --quiet)"
13case $svn_ver in
140.* | 1.[0-4].*)
15 skip_all="skipping git-svn test - SVN too old ($svn_ver)"
16 test_done
17 ;;
18esac
19
20# ... a - b - m <- trunk
21# \ /
22# ... c <- branch1
23#
24# SVN Commits not interesting for this test are abbreviated with "..."
25#
26test_expect_success 'initialize source svn repo' '
27 svn_cmd mkdir -m "create trunk" "$svnrepo"/trunk &&
28 svn_cmd mkdir -m "create branches" "$svnrepo/branches" &&
29 svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
30 (
31 cd "$SVN_TREE" &&
32 touch foo &&
33 svn_cmd add foo &&
34 svn_cmd commit -m "a" &&
35 svn_cmd cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
36 svn_cmd switch "$svnrepo"/branches/branch1 &&
37 touch bar &&
38 svn_cmd add bar &&
39 svn_cmd commit -m b &&
40 svn_cmd switch "$svnrepo"/trunk &&
41 touch baz &&
42 svn_cmd add baz &&
43 svn_cmd commit -m c &&
44 svn_cmd up &&
45 svn_cmd merge "$svnrepo"/branches/branch1 &&
46 svn_cmd commit -m "m"
47 ) &&
48 rm -rf "$SVN_TREE"
49'
50
51test_expect_success 'fetch to merge-base (a)' '
52 git svn init -s "$svnrepo" &&
53 git svn fetch --revision BASE:3
54'
55
56# git svn rebase looses the merge commit
57#
58# ... a - b - m <- trunk
59# \
60# ... c
61#
62test_expect_success 'rebase looses SVN merge (m)' '
63 git svn rebase &&
64 git svn fetch &&
Johannes Schindelina881baa2020-11-18 23:44:42 +000065 test 1 = $(git cat-file -p main|grep parent|wc -l)
Peter Baumann61b472e2012-08-09 08:42:53 +020066'
67
68# git svn fetch creates correct history with merge commit
69#
70# ... a - b - m <- trunk
71# \ /
72# ... c <- branch1
73#
74test_expect_success 'reset and fetch gets the SVN merge (m) correctly' '
75 git svn reset -r 3 &&
Johan Herlandfe191fc2013-10-11 14:57:07 +020076 git reset --hard origin/trunk &&
Peter Baumann61b472e2012-08-09 08:42:53 +020077 git svn fetch &&
Johan Herlandfe191fc2013-10-11 14:57:07 +020078 test 2 = $(git cat-file -p origin/trunk|grep parent|wc -l)
Peter Baumann61b472e2012-08-09 08:42:53 +020079'
80
81test_done