3 # Copyright (c) 2005 Petr Baudis
5 test_description
="Tests cg-fetch over rsync
7 cg-fetch over rsync - if it works at all, and if it catches missing objects."
11 # Trick to be able to use the rsync:// URLs locally. That's not something
12 # we want the regular user to do, but it's handy for testing, so our tool
13 # will just strip 'rsync://local/' from the URL start, leaving the rest
15 export RSYNC
="$(pwd)/localrsync"
20 args[\${#args[@]}]="\$(echo "\$arg" | sed 's#rsync://local/#$(pwd | sed 's/#/\\#/g')/#')"
27 test_expect_success
'verifying repo2' \
28 "(cmp repo2/.git/refs/heads/origin repo2/.git/refs/heads/master &&
29 cd repo2 && git-fsck-objects)"
33 echo stuff
>repo
1/file
34 test_expect_success
'initialize repo1' \
35 "(cd repo1 && cg-init -I && cg-add file && cg-commit -C -m\"Initial commit\")"
36 test_expect_success
'clone repo2' \
37 "(cg-clone rsync://local/repo1/.git repo2 &&
38 cmp repo2/.git/refs/heads/origin repo1/.git/refs/heads/master)"
41 echo more stuff
>>repo
1/file
42 test_expect_success
'local commit in repo1' \
43 "(cd repo1 && git-update-index file && cg-commit -m\"Second commit\")"
44 test_expect_success
'updating repo2' \
45 "(cd repo2 && cg-update &&
46 cmp .git/refs/heads/origin ../repo1/.git/refs/heads/master)"
49 echo more more stuff
>>repo
1/file
50 test_expect_success
'local commit in repo1' \
51 "(cd repo1 && git-update-index file && cg-commit -m\"Third commit\")"
52 test_expect_success
'rewriting HEAD of repo1 to symbolic' \
53 '(rm repo1/.git/HEAD && echo "ref: refs/heads/master" >repo1/.git/HEAD)'
54 test_expect_success
'updating repo2' \
55 "(cd repo2 && cg-update &&
56 cmp .git/refs/heads/origin ../repo1/.git/refs/heads/master)"
59 echo even
more stuff
>>repo
1/file
60 test_expect_success
'local commit in repo1' \
61 "(cd repo1 && git-update-index file && cg-commit -m\"Fourth commit\")"
62 obj
="$(cd repo1 && cg-admin-ls file | cut -f 1 | cut -d ' ' -f 3)"
63 test_expect_success
'damaging repo1' \
64 "(cd repo1 && rm -f .git/objects/${obj:0:2}/${obj:2})"
65 test_expect_failure
'updating repo2' \
66 "(cd repo2 && cg-fetch)" # to prevent merge failing too late