An illustration of rev-list --parents --pretty=raw
[git/vmiklos.git] / t / t5400-send-pack.sh
blob8afb89971752fe4a91b9b7c62b4b0a6b69a8272b
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='See why rewinding head breaks send-pack
9 . ./test-lib.sh
11 touch cpio-test
12 test_expect_success 'working cpio' 'echo cpio-test | cpio -o > /dev/null'
14 cnt='1'
15 test_expect_success setup '
16 tree=$(git-write-tree) &&
17 commit=$(echo "Commit #0" | git-commit-tree $tree) &&
18 zero=$commit &&
19 parent=$zero &&
20 for i in $cnt
22 sleep 1 &&
23 commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) &&
24 parent=$commit || return 1
25 done &&
26 git-update-ref HEAD "$commit" &&
27 git-clone -l ./. victim &&
28 cd victim &&
29 git-log &&
30 cd .. &&
31 git-update-ref HEAD "$zero" &&
32 parent=$zero &&
33 for i in $cnt
35 sleep 1 &&
36 commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) &&
37 parent=$commit || return 1
38 done &&
39 git-update-ref HEAD "$commit" &&
40 echo Rebase &&
41 git-log'
43 test_expect_success \
44 'pushing rewound head should not barf but require --force' '
45 # should not fail but refuse to update.
46 if git-send-pack ./victim/.git/ master
47 then
48 # now it should fail with Pasky patch
49 echo >&2 Gaah, it should have failed.
50 false
51 else
52 echo >&2 Thanks, it correctly failed.
53 true
54 fi &&
55 if cmp victim/.git/refs/heads/master .git/refs/heads/master
56 then
57 # should have been left as it was!
58 false
59 else
60 true
61 fi &&
62 # this should update
63 git-send-pack --force ./victim/.git/ master &&
64 cmp victim/.git/refs/heads/master .git/refs/heads/master
67 unset GIT_CONFIG GIT_CONFIG_LOCAL
68 HOME=`pwd`/no-such-directory
69 export HOME ;# this way we force the victim/.git/config to be used.
71 test_expect_success \
72 'pushing with --force should be denied with denyNonFastforwards' '
73 cd victim &&
74 git-repo-config receive.denyNonFastforwards true &&
75 cd .. &&
76 git-update-ref refs/heads/master master^ &&
77 git-send-pack --force ./victim/.git/ master &&
78 ! diff -u .git/refs/heads/master victim/.git/refs/heads/master
81 test_done