diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-09-07 15:24:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-09-07 15:24:47 -0700 |
commit | e4d1afbcf2e39a997ae90befd629ee53e444c4c9 (patch) | |
tree | cf73286b1455877aa3c09dd059fcc42a61b6a16a /t | |
parent | 54f0bdc81103f45f12978b385a9519a235b03cc2 (diff) | |
parent | 11cae066b2433fcec807810b45f317f8203df358 (diff) | |
download | git-e4d1afbcf2e39a997ae90befd629ee53e444c4c9.tar.gz git-e4d1afbcf2e39a997ae90befd629ee53e444c4c9.tar.xz |
Merge branch 'jc/upload-pack-hook'
* jc/upload-pack-hook:
upload-pack: feed "kind [clone|fetch]" to post-upload-pack hook
upload-pack: add a trigger for post-upload-pack hook
Diffstat (limited to 't')
-rwxr-xr-x | t/t5501-post-upload-pack.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/t/t5501-post-upload-pack.sh b/t/t5501-post-upload-pack.sh new file mode 100755 index 000000000..d89fb51ba --- /dev/null +++ b/t/t5501-post-upload-pack.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +test_description='post upload-hook' + +. ./test-lib.sh + +LOGFILE=".git/post-upload-pack-log" + +test_expect_success setup ' + test_commit A && + test_commit B && + git reset --hard A && + test_commit C && + git branch prev B && + mkdir -p .git/hooks && + { + echo "#!$SHELL_PATH" && + echo "cat >post-upload-pack-log" + } >".git/hooks/post-upload-pack" && + chmod +x .git/hooks/post-upload-pack +' + +test_expect_success initial ' + rm -fr sub && + git init sub && + ( + cd sub && + git fetch --no-tags .. prev + ) && + want=$(sed -n "s/^want //p" "$LOGFILE") && + test "$want" = "$(git rev-parse --verify B)" && + ! grep "^have " "$LOGFILE" && + kind=$(sed -n "s/^kind //p" "$LOGFILE") && + test "$kind" = fetch +' + +test_expect_success second ' + rm -fr sub && + git init sub && + ( + cd sub && + git fetch --no-tags .. prev:refs/remotes/prev && + git fetch --no-tags .. master + ) && + want=$(sed -n "s/^want //p" "$LOGFILE") && + test "$want" = "$(git rev-parse --verify C)" && + have=$(sed -n "s/^have //p" "$LOGFILE") && + test "$have" = "$(git rev-parse --verify B)" && + kind=$(sed -n "s/^kind //p" "$LOGFILE") && + test "$kind" = fetch +' + +test_expect_success all ' + rm -fr sub && + HERE=$(pwd) && + git init sub && + ( + cd sub && + git clone "file://$HERE/.git" new + ) && + sed -n "s/^want //p" "$LOGFILE" | sort >actual && + git rev-parse A B C | sort >expect && + test_cmp expect actual && + ! grep "^have " "$LOGFILE" && + kind=$(sed -n "s/^kind //p" "$LOGFILE") && + test "$kind" = clone +' + +test_done |