Skip to content

Commit 6b3fa7e

Browse files
spearcegitster
authored andcommitted
t5401: Use a bare repository for the remote peer
We want to avoid the warnings (or later, test failures) about updating the current branch. It was never my intention to have this test deal with a repository with a working directory, and it is a very old bug that the test even used a non-bare repository for the remote side of the push operations. This fixes the interleaved output error we were seeing as a test failure by avoiding the giant warning message we were getting back about updating the current branch being risky. Its not a real fix, but is something we should do no matter what, because the behavior will change in the future to reject, and the test would break at that time. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d525d3 commit 6b3fa7e

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

t/t5401-update-hooks.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,100 +17,100 @@ test_expect_success setup '
1717
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
1818
git update-ref refs/heads/master $commit0 &&
1919
git update-ref refs/heads/tofail $commit1 &&
20-
git clone ./. victim &&
21-
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 &&
2222
git update-ref refs/heads/master $commit1 &&
2323
git update-ref refs/heads/tofail $commit0
2424
'
2525

26-
cat >victim/.git/hooks/pre-receive <<'EOF'
26+
cat >victim.git/hooks/pre-receive <<'EOF'
2727
#!/bin/sh
2828
printf %s "$@" >>$GIT_DIR/pre-receive.args
2929
cat - >$GIT_DIR/pre-receive.stdin
3030
echo STDOUT pre-receive
3131
echo STDERR pre-receive >&2
3232
EOF
33-
chmod u+x victim/.git/hooks/pre-receive
33+
chmod u+x victim.git/hooks/pre-receive
3434

35-
cat >victim/.git/hooks/update <<'EOF'
35+
cat >victim.git/hooks/update <<'EOF'
3636
#!/bin/sh
3737
echo "$@" >>$GIT_DIR/update.args
3838
read x; printf %s "$x" >$GIT_DIR/update.stdin
3939
echo STDOUT update $1
4040
echo STDERR update $1 >&2
4141
test "$1" = refs/heads/master || exit
4242
EOF
43-
chmod u+x victim/.git/hooks/update
43+
chmod u+x victim.git/hooks/update
4444

45-
cat >victim/.git/hooks/post-receive <<'EOF'
45+
cat >victim.git/hooks/post-receive <<'EOF'
4646
#!/bin/sh
4747
printf %s "$@" >>$GIT_DIR/post-receive.args
4848
cat - >$GIT_DIR/post-receive.stdin
4949
echo STDOUT post-receive
5050
echo STDERR post-receive >&2
5151
EOF
52-
chmod u+x victim/.git/hooks/post-receive
52+
chmod u+x victim.git/hooks/post-receive
5353

54-
cat >victim/.git/hooks/post-update <<'EOF'
54+
cat >victim.git/hooks/post-update <<'EOF'
5555
#!/bin/sh
5656
echo "$@" >>$GIT_DIR/post-update.args
5757
read x; printf %s "$x" >$GIT_DIR/post-update.stdin
5858
echo STDOUT post-update
5959
echo STDERR post-update >&2
6060
EOF
61-
chmod u+x victim/.git/hooks/post-update
61+
chmod u+x victim.git/hooks/post-update
6262

6363
test_expect_success push '
64-
test_must_fail git send-pack --force ./victim/.git \
64+
test_must_fail git send-pack --force ./victim.git \
6565
master tofail >send.out 2>send.err
6666
'
6767

6868
test_expect_success 'updated as expected' '
69-
test $(GIT_DIR=victim/.git git rev-parse master) = $commit1 &&
70-
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
7171
'
7272

7373
test_expect_success 'hooks ran' '
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
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
8282
'
8383

8484
test_expect_success 'pre-receive hook input' '
8585
(echo $commit0 $commit1 refs/heads/master;
8686
echo $commit1 $commit0 refs/heads/tofail
87-
) | test_cmp - victim/.git/pre-receive.stdin
87+
) | test_cmp - victim.git/pre-receive.stdin
8888
'
8989

9090
test_expect_success 'update hook arguments' '
9191
(echo refs/heads/master $commit0 $commit1;
9292
echo refs/heads/tofail $commit1 $commit0
93-
) | test_cmp - victim/.git/update.args
93+
) | test_cmp - victim.git/update.args
9494
'
9595

9696
test_expect_success 'post-receive hook input' '
9797
echo $commit0 $commit1 refs/heads/master |
98-
test_cmp - victim/.git/post-receive.stdin
98+
test_cmp - victim.git/post-receive.stdin
9999
'
100100

101101
test_expect_success 'post-update hook arguments' '
102102
echo refs/heads/master |
103-
test_cmp - victim/.git/post-update.args
103+
test_cmp - victim.git/post-update.args
104104
'
105105

106106
test_expect_success 'all hook stdin is /dev/null' '
107-
! test -s victim/.git/update.stdin &&
108-
! test -s victim/.git/post-update.stdin
107+
! test -s victim.git/update.stdin &&
108+
! test -s victim.git/post-update.stdin
109109
'
110110

111111
test_expect_success 'all *-receive hook args are empty' '
112-
! test -s victim/.git/pre-receive.args &&
113-
! test -s victim/.git/post-receive.args
112+
! test -s victim.git/pre-receive.args &&
113+
! test -s victim.git/post-receive.args
114114
'
115115

116116
test_expect_success 'send-pack produced no output' '

0 commit comments

Comments
 (0)