Merge branch 'maint'
[git] / t / t5800-remote-helpers.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Sverre Rabbelier
4 #
5
6 test_description='Test remote-helper import and export commands'
7
8 . ./test-lib.sh
9
10 if test_have_prereq PYTHON && "$PYTHON_PATH" -c '
11 import sys
12 if sys.hexversion < 0x02040000:
13     sys.exit(1)
14 '
15 then
16         :
17 else
18         say 'skipping git remote-testgit tests: requires Python 2.4 or newer'
19         test_done
20 fi
21
22 test_expect_success 'setup repository' '
23         git init --bare server/.git &&
24         git clone server public &&
25         (cd public &&
26          echo content >file &&
27          git add file &&
28          git commit -m one &&
29          git push origin master)
30 '
31
32 test_expect_success 'cloning from local repo' '
33         git clone "testgit::${PWD}/server" localclone &&
34         test_cmp public/file localclone/file
35 '
36
37 test_expect_success 'cloning from remote repo' '
38         git clone "testgit::file://${PWD}/server" clone &&
39         test_cmp public/file clone/file
40 '
41
42 test_expect_success 'create new commit on remote' '
43         (cd public &&
44          echo content >>file &&
45          git commit -a -m two &&
46          git push)
47 '
48
49 test_expect_success 'pulling from local repo' '
50         (cd localclone && git pull) &&
51         test_cmp public/file localclone/file
52 '
53
54 test_expect_success 'pulling from remote remote' '
55         (cd clone && git pull) &&
56         test_cmp public/file clone/file
57 '
58
59 test_expect_success 'pushing to local repo' '
60         (cd localclone &&
61         echo content >>file &&
62         git commit -a -m three &&
63         git push) &&
64         HEAD=$(git --git-dir=localclone/.git rev-parse --verify HEAD) &&
65         test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
66 '
67
68 test_expect_success 'synch with changes from localclone' '
69         (cd clone &&
70          git pull)
71 '
72
73 test_expect_success 'pushing remote local repo' '
74         (cd clone &&
75         echo content >>file &&
76         git commit -a -m four &&
77         git push) &&
78         HEAD=$(git --git-dir=clone/.git rev-parse --verify HEAD) &&
79         test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
80 '
81
82 test_done