@@ -17,101 +17,100 @@ test_expect_success setup '
17
17
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
18
18
git update-ref refs/heads/master $commit0 &&
19
19
git update-ref refs/heads/tofail $commit1 &&
20
- git clone ./. victim &&
21
- GIT_DIR=victim/.git git config receive.denyCurrentBranch warn &&
22
- GIT_DIR=victim/.git git update-ref refs/heads/tofail $commit1 &&
20
+ git clone --bare ./. victim.git &&
21
+ GIT_DIR=victim.git git update-ref refs/heads/tofail $commit1 &&
23
22
git update-ref refs/heads/master $commit1 &&
24
23
git update-ref refs/heads/tofail $commit0
25
24
'
26
25
27
- cat > victim/ .git/hooks/pre-receive << 'EOF '
26
+ cat > victim.git/hooks/pre-receive << 'EOF '
28
27
#!/bin/sh
29
28
printf %s "$@" >>$GIT_DIR/pre-receive.args
30
29
cat - >$GIT_DIR/pre-receive.stdin
31
30
echo STDOUT pre-receive
32
31
echo STDERR pre-receive >&2
33
32
EOF
34
- chmod u+x victim/ .git/hooks/pre-receive
33
+ chmod u+x victim.git/hooks/pre-receive
35
34
36
- cat > victim/ .git/hooks/update << 'EOF '
35
+ cat > victim.git/hooks/update << 'EOF '
37
36
#!/bin/sh
38
37
echo "$@" >>$GIT_DIR/update.args
39
38
read x; printf %s "$x" >$GIT_DIR/update.stdin
40
39
echo STDOUT update $1
41
40
echo STDERR update $1 >&2
42
41
test "$1" = refs/heads/master || exit
43
42
EOF
44
- chmod u+x victim/ .git/hooks/update
43
+ chmod u+x victim.git/hooks/update
45
44
46
- cat > victim/ .git/hooks/post-receive << 'EOF '
45
+ cat > victim.git/hooks/post-receive << 'EOF '
47
46
#!/bin/sh
48
47
printf %s "$@" >>$GIT_DIR/post-receive.args
49
48
cat - >$GIT_DIR/post-receive.stdin
50
49
echo STDOUT post-receive
51
50
echo STDERR post-receive >&2
52
51
EOF
53
- chmod u+x victim/ .git/hooks/post-receive
52
+ chmod u+x victim.git/hooks/post-receive
54
53
55
- cat > victim/ .git/hooks/post-update << 'EOF '
54
+ cat > victim.git/hooks/post-update << 'EOF '
56
55
#!/bin/sh
57
56
echo "$@" >>$GIT_DIR/post-update.args
58
57
read x; printf %s "$x" >$GIT_DIR/post-update.stdin
59
58
echo STDOUT post-update
60
59
echo STDERR post-update >&2
61
60
EOF
62
- chmod u+x victim/ .git/hooks/post-update
61
+ chmod u+x victim.git/hooks/post-update
63
62
64
63
test_expect_success push '
65
- test_must_fail git send-pack --force ./victim/ .git \
64
+ test_must_fail git send-pack --force ./victim.git \
66
65
master tofail >send.out 2>send.err
67
66
'
68
67
69
68
test_expect_success ' updated as expected' '
70
- test $(GIT_DIR=victim/ .git git rev-parse master) = $commit1 &&
71
- test $(GIT_DIR=victim/ .git git rev-parse tofail) = $commit1
69
+ test $(GIT_DIR=victim.git git rev-parse master) = $commit1 &&
70
+ test $(GIT_DIR=victim.git git rev-parse tofail) = $commit1
72
71
'
73
72
74
73
test_expect_success ' hooks ran' '
75
- test -f victim/ .git/pre-receive.args &&
76
- test -f victim/ .git/pre-receive.stdin &&
77
- test -f victim/ .git/update.args &&
78
- test -f victim/ .git/update.stdin &&
79
- test -f victim/ .git/post-receive.args &&
80
- test -f victim/ .git/post-receive.stdin &&
81
- test -f victim/ .git/post-update.args &&
82
- test -f victim/ .git/post-update.stdin
74
+ test -f victim.git/pre-receive.args &&
75
+ test -f victim.git/pre-receive.stdin &&
76
+ test -f victim.git/update.args &&
77
+ test -f victim.git/update.stdin &&
78
+ test -f victim.git/post-receive.args &&
79
+ test -f victim.git/post-receive.stdin &&
80
+ test -f victim.git/post-update.args &&
81
+ test -f victim.git/post-update.stdin
83
82
'
84
83
85
84
test_expect_success ' pre-receive hook input' '
86
85
(echo $commit0 $commit1 refs/heads/master;
87
86
echo $commit1 $commit0 refs/heads/tofail
88
- ) | test_cmp - victim/ .git/pre-receive.stdin
87
+ ) | test_cmp - victim.git/pre-receive.stdin
89
88
'
90
89
91
90
test_expect_success ' update hook arguments' '
92
91
(echo refs/heads/master $commit0 $commit1;
93
92
echo refs/heads/tofail $commit1 $commit0
94
- ) | test_cmp - victim/ .git/update.args
93
+ ) | test_cmp - victim.git/update.args
95
94
'
96
95
97
96
test_expect_success ' post-receive hook input' '
98
97
echo $commit0 $commit1 refs/heads/master |
99
- test_cmp - victim/ .git/post-receive.stdin
98
+ test_cmp - victim.git/post-receive.stdin
100
99
'
101
100
102
101
test_expect_success ' post-update hook arguments' '
103
102
echo refs/heads/master |
104
- test_cmp - victim/ .git/post-update.args
103
+ test_cmp - victim.git/post-update.args
105
104
'
106
105
107
106
test_expect_success ' all hook stdin is /dev/null' '
108
- ! test -s victim/ .git/update.stdin &&
109
- ! test -s victim/ .git/post-update.stdin
107
+ ! test -s victim.git/update.stdin &&
108
+ ! test -s victim.git/post-update.stdin
110
109
'
111
110
112
111
test_expect_success ' all *-receive hook args are empty' '
113
- ! test -s victim/ .git/pre-receive.args &&
114
- ! test -s victim/ .git/post-receive.args
112
+ ! test -s victim.git/pre-receive.args &&
113
+ ! test -s victim.git/post-receive.args
115
114
'
116
115
117
116
test_expect_success ' send-pack produced no output' '
@@ -125,14 +124,15 @@ remote: STDOUT update refs/heads/master
125
124
remote: STDERR update refs/heads/master
126
125
remote: STDOUT update refs/heads/tofail
127
126
remote: STDERR update refs/heads/tofail
127
+ remote: error: hook declined to update refs/heads/tofail
128
128
remote: STDOUT post-receive
129
129
remote: STDERR post-receive
130
130
remote: STDOUT post-update
131
131
remote: STDERR post-update
132
132
EOF
133
133
test_expect_success ' send-pack stderr contains hook messages' '
134
134
grep ^remote: send.err | sed "s/ *\$//" >actual &&
135
- test_cmp - actual <expect
135
+ test_cmp expect actual
136
136
'
137
137
138
138
test_done
0 commit comments