3 # Copyright (c) 2005 Junio C Hamano
6 test_description='See why rewinding head breaks send-pack
12 test_expect_success 'working cpio' 'echo cpio-test | cpio -o > /dev/null'
15 test_expect_success setup '
16 tree=$(git-write-tree) &&
17 commit=$(echo "Commit #0" | git-commit-tree $tree) &&
23 commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) &&
24 parent=$commit || return 1
26 git-update-ref HEAD "$commit" &&
27 git-clone -l ./. victim &&
31 git-update-ref HEAD "$zero" &&
36 commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) &&
37 parent=$commit || return 1
39 git-update-ref HEAD "$commit" &&
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
48 # now it should fail with Pasky patch
49 echo >&2 Gaah, it should have failed.
52 echo >&2 Thanks, it correctly failed.
55 if cmp victim/.git/refs/heads/master .git/refs/heads/master
57 # should have been left as it was!
63 git-send-pack --force ./victim/.git/ master &&
64 cmp victim/.git/refs/heads/master .git/refs/heads/master
68 'push can be used to delete a ref' '
70 git branch extra master &&
72 test -f victim/.git/refs/heads/extra &&
73 git-send-pack ./victim/.git/ :extra master &&
74 ! test -f victim/.git/refs/heads/extra
77 unset GIT_CONFIG GIT_CONFIG_LOCAL
78 HOME=`pwd`/no-such-directory
79 export HOME ;# this way we force the victim/.git/config to be used.
82 'pushing with --force should be denied with denyNonFastforwards' '
84 git-repo-config receive.denyNonFastforwards true &&
86 git-update-ref refs/heads/master master^ &&
87 git-send-pack --force ./victim/.git/ master &&
88 ! diff -u .git/refs/heads/master victim/.git/refs/heads/master