]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5800-remote-helpers.sh
Merge branch 'jm/maint-apply-detects-corrupt-patch-header' into maint
[thirdparty/git.git] / t / t5800-remote-helpers.sh
CommitLineData
2cb5a481
SR
1#!/bin/sh
2#
3# Copyright (c) 2010 Sverre Rabbelier
4#
5
6test_description='Test remote-helper import and export commands'
7
8. ./test-lib.sh
9
760fec7d
SR
10if ! test_have_prereq PYTHON ; then
11 skip_all='skipping git-remote-hg tests, python not available'
12 test_done
13fi
14
15"$PYTHON_PATH" -c '
2bf10334 16import sys
23b093ee 17if sys.hexversion < 0x02040000:
2bf10334 18 sys.exit(1)
760fec7d
SR
19' || {
20 skip_all='skipping git-remote-hg tests, python version < 2.4'
21 test_done
22}
63a2f613 23
5cf5ade3
JK
24compare_refs() {
25 git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
26 git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
27 test_cmp expect actual
28}
29
760fec7d 30test_expect_success 'setup repository' '
2cb5a481
SR
31 git init --bare server/.git &&
32 git clone server public &&
33 (cd public &&
34 echo content >file &&
35 git add file &&
36 git commit -m one &&
37 git push origin master)
38'
39
760fec7d 40test_expect_success 'cloning from local repo' '
2cb5a481
SR
41 git clone "testgit::${PWD}/server" localclone &&
42 test_cmp public/file localclone/file
43'
44
760fec7d 45test_expect_success 'cloning from remote repo' '
2cb5a481
SR
46 git clone "testgit::file://${PWD}/server" clone &&
47 test_cmp public/file clone/file
48'
49
760fec7d 50test_expect_success 'create new commit on remote' '
2cb5a481
SR
51 (cd public &&
52 echo content >>file &&
53 git commit -a -m two &&
54 git push)
55'
56
760fec7d 57test_expect_success 'pulling from local repo' '
2cb5a481
SR
58 (cd localclone && git pull) &&
59 test_cmp public/file localclone/file
60'
61
760fec7d 62test_expect_success 'pulling from remote remote' '
2cb5a481
SR
63 (cd clone && git pull) &&
64 test_cmp public/file clone/file
65'
66
760fec7d 67test_expect_success 'pushing to local repo' '
2cb5a481
SR
68 (cd localclone &&
69 echo content >>file &&
70 git commit -a -m three &&
71 git push) &&
5cf5ade3 72 compare_refs localclone HEAD server HEAD
2cb5a481
SR
73'
74
760fec7d 75test_expect_success 'synch with changes from localclone' '
2cb5a481
SR
76 (cd clone &&
77 git pull)
78'
79
760fec7d 80test_expect_success 'pushing remote local repo' '
2cb5a481
SR
81 (cd clone &&
82 echo content >>file &&
83 git commit -a -m four &&
84 git push) &&
5cf5ade3 85 compare_refs clone HEAD server HEAD
2cb5a481
SR
86'
87
4e51ba23 88test_expect_success 'fetch new branch' '
c00dd33b
JK
89 (cd public &&
90 git checkout -b new &&
91 echo content >>file &&
92 git commit -a -m five &&
93 git push origin new
94 ) &&
95 (cd localclone &&
96 git fetch origin new
97 ) &&
98 compare_refs public HEAD localclone FETCH_HEAD
99'
100
9504bc9d 101test_expect_success 'fetch multiple branches' '
c00dd33b
JK
102 (cd localclone &&
103 git fetch
104 ) &&
105 compare_refs server master localclone refs/remotes/origin/master &&
106 compare_refs server new localclone refs/remotes/origin/new
107'
108
3ea7d094 109test_expect_success 'push when remote has extra refs' '
c00dd33b
JK
110 (cd clone &&
111 echo content >>file &&
112 git commit -a -m six &&
113 git push
114 ) &&
115 compare_refs clone master server master
116'
117
b4b87299 118test_expect_success 'push new branch by name' '
c00dd33b
JK
119 (cd clone &&
120 git checkout -b new-name &&
121 echo content >>file &&
122 git commit -a -m seven &&
123 git push origin new-name
124 ) &&
125 compare_refs clone HEAD server refs/heads/new-name
126'
127
128test_expect_failure 'push new branch with old:new refspec' '
129 (cd clone &&
130 git push origin new-name:new-refspec
131 ) &&
132 compare_refs clone HEAD server refs/heads/new-refspec
133'
134
2cb5a481 135test_done