diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index 036f6c7997..c308d2943c 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -332,6 +332,10 @@ time float:: size decimal:: Size of the resulting packfile in bytes. +kind string: + Either "clone" (when the client did not give us any "have", and asked + for all our refs with "want"), or "fetch" (otherwise). + pre-auto-gc ----------- diff --git a/t/t5501-post-upload-pack.sh b/t/t5501-post-upload-pack.sh index 47ee7b5039..d89fb51bad 100755 --- a/t/t5501-post-upload-pack.sh +++ b/t/t5501-post-upload-pack.sh @@ -29,7 +29,9 @@ test_expect_success initial ' ) && want=$(sed -n "s/^want //p" "$LOGFILE") && test "$want" = "$(git rev-parse --verify B)" && - ! grep "^have " "$LOGFILE" + ! grep "^have " "$LOGFILE" && + kind=$(sed -n "s/^kind //p" "$LOGFILE") && + test "$kind" = fetch ' test_expect_success second ' @@ -43,7 +45,25 @@ test_expect_success second ' 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)" + 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 diff --git a/upload-pack.c b/upload-pack.c index 857440d579..8e82179c93 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -187,6 +187,10 @@ static int run_post_upload_pack_hook(size_t total, struct timeval *tv) (long)tv->tv_sec, (long)tv->tv_usec); if (!err) err |= feed_msg_to_hook(proc.in, "size %ld\n", (long)total); + if (!err) + err |= feed_msg_to_hook(proc.in, "kind %s\n", + (nr_our_refs == want_obj.nr && !have_obj.nr) + ? "clone" : "fetch"); if (close(proc.in)) err = 1; if (finish_command(&proc))