smart-http: support shallow fetch/clone
[gitweb.git] / builtin / send-pack.c
index faaa603843975aa41c0e8aa6fc270017405f3375..664dd20f407dffed002d63b8dab5a83079463445 100644 (file)
@@ -101,6 +101,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        int fd[2];
        struct child_process *conn;
        struct sha1_array extra_have = SHA1_ARRAY_INIT;
+       struct sha1_array shallow = SHA1_ARRAY_INIT;
        struct ref *remote_refs, *local_refs;
        int ret;
        int helper_status = 0;
@@ -208,6 +209,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
            (send_all && args.send_mirror))
                usage(send_pack_usage);
 
+       if (is_repository_shallow() && args.stateless_rpc)
+               die("attempt to push from a shallow repository");
+
        if (remote_name) {
                remote = remote_get(remote_name);
                if (!remote_has_url(remote, dest)) {
@@ -229,7 +233,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                        args.verbose ? CONNECT_VERBOSE : 0);
        }
 
-       get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have);
+       get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL,
+                        &extra_have, &shallow);
 
        transport_verify_remote_names(nr_refspecs, refspecs);