summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/githooks.txt4
-rwxr-xr-xt/t5501-post-upload-pack.sh24
-rw-r--r--upload-pack.c4
3 files changed, 30 insertions, 2 deletions
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 036f6c7..c308d29 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 47ee7b5..d89fb51 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 857440d..8e82179 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))