upload-pack: add a trigger for post-upload-pack hook
[git/dscho.git] / t / t5501-post-upload-pack.sh
blob47ee7b5039a02d0bc5ca3a3ada305ac860d3aaa8
1 #!/bin/sh
3 test_description='post upload-hook'
5 . ./test-lib.sh
7 LOGFILE=".git/post-upload-pack-log"
9 test_expect_success setup '
10 test_commit A &&
11 test_commit B &&
12 git reset --hard A &&
13 test_commit C &&
14 git branch prev B &&
15 mkdir -p .git/hooks &&
17 echo "#!$SHELL_PATH" &&
18 echo "cat >post-upload-pack-log"
19 } >".git/hooks/post-upload-pack" &&
20 chmod +x .git/hooks/post-upload-pack
23 test_expect_success initial '
24 rm -fr sub &&
25 git init sub &&
27 cd sub &&
28 git fetch --no-tags .. prev
29 ) &&
30 want=$(sed -n "s/^want //p" "$LOGFILE") &&
31 test "$want" = "$(git rev-parse --verify B)" &&
32 ! grep "^have " "$LOGFILE"
35 test_expect_success second '
36 rm -fr sub &&
37 git init sub &&
39 cd sub &&
40 git fetch --no-tags .. prev:refs/remotes/prev &&
41 git fetch --no-tags .. master
42 ) &&
43 want=$(sed -n "s/^want //p" "$LOGFILE") &&
44 test "$want" = "$(git rev-parse --verify C)" &&
45 have=$(sed -n "s/^have //p" "$LOGFILE") &&
46 test "$have" = "$(git rev-parse --verify B)"
49 test_done