prune: --grace=time
[git/git.git] / t / t5400-send-pack.sh
CommitLineData
bdf25142
LT
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='See why rewinding head breaks send-pack
7
8'
9. ./test-lib.sh
10
04509738 11cnt=64
bdf25142 12test_expect_success setup '
04509738
JH
13 test_tick &&
14 mkdir mozart mozart/is &&
15 echo "Commit #0" >mozart/is/pink &&
16 git-update-index --add mozart/is/pink &&
bdf25142
LT
17 tree=$(git-write-tree) &&
18 commit=$(echo "Commit #0" | git-commit-tree $tree) &&
19 zero=$commit &&
20 parent=$zero &&
04509738
JH
21 i=0 &&
22 while test $i -le $cnt
bdf25142 23 do
04509738
JH
24 i=$(($i+1)) &&
25 test_tick &&
26 echo "Commit #$i" >mozart/is/pink &&
27 git-update-index --add mozart/is/pink &&
28 tree=$(git-write-tree) &&
bdf25142 29 commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) &&
04509738 30 git-update-ref refs/tags/commit$i $commit &&
4d9d62fa 31 parent=$commit || return 1
bdf25142 32 done &&
8098a178 33 git-update-ref HEAD "$commit" &&
04509738 34 git-clone ./. victim &&
bdf25142 35 cd victim &&
bc6146d2 36 git-log &&
bdf25142 37 cd .. &&
8098a178 38 git-update-ref HEAD "$zero" &&
bdf25142 39 parent=$zero &&
04509738
JH
40 i=0 &&
41 while test $i -le $cnt
bdf25142 42 do
04509738
JH
43 i=$(($i+1)) &&
44 test_tick &&
45 echo "Rebase #$i" >mozart/is/pink &&
46 git-update-index --add mozart/is/pink &&
47 tree=$(git-write-tree) &&
bdf25142 48 commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) &&
04509738 49 git-update-ref refs/tags/rebase$i $commit &&
4d9d62fa 50 parent=$commit || return 1
bdf25142 51 done &&
8098a178 52 git-update-ref HEAD "$commit" &&
bdf25142 53 echo Rebase &&
bc6146d2 54 git-log'
bdf25142 55
04509738
JH
56test_expect_success 'pack the source repository' '
57 git repack -a -d &&
9b088c4e 58 git prune --grace=off
04509738
JH
59'
60
61test_expect_success 'pack the destination repository' '
62 cd victim &&
63 git repack -a -d &&
9b088c4e 64 git prune --grace=off &&
04509738
JH
65 cd ..
66'
67
bdf25142
LT
68test_expect_success \
69 'pushing rewound head should not barf but require --force' '
70 # should not fail but refuse to update.
ed24928e
PB
71 if git-send-pack ./victim/.git/ master
72 then
73 # now it should fail with Pasky patch
74 echo >&2 Gaah, it should have failed.
75 false
76 else
77 echo >&2 Thanks, it correctly failed.
78 true
79 fi &&
bdf25142
LT
80 if cmp victim/.git/refs/heads/master .git/refs/heads/master
81 then
82 # should have been left as it was!
83 false
84 else
85 true
86 fi &&
87 # this should update
88 git-send-pack --force ./victim/.git/ master &&
89 cmp victim/.git/refs/heads/master .git/refs/heads/master
90'
da7bc9b0 91
d4f694ba
JH
92test_expect_success \
93 'push can be used to delete a ref' '
94 cd victim &&
95 git branch extra master &&
96 cd .. &&
97 test -f victim/.git/refs/heads/extra &&
98 git-send-pack ./victim/.git/ :extra master &&
99 ! test -f victim/.git/refs/heads/extra
100'
101
199a9218
JS
102unset GIT_CONFIG GIT_CONFIG_LOCAL
103HOME=`pwd`/no-such-directory
104export HOME ;# this way we force the victim/.git/config to be used.
105
106test_expect_success \
107 'pushing with --force should be denied with denyNonFastforwards' '
108 cd victim &&
109 git-repo-config receive.denyNonFastforwards true &&
110 cd .. &&
111 git-update-ref refs/heads/master master^ &&
112 git-send-pack --force ./victim/.git/ master &&
113 ! diff -u .git/refs/heads/master victim/.git/refs/heads/master
114'
115
da7bc9b0 116test_done