Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 builtin/send-pack.c     |  4 +++-
 t/t5537-push-shallow.sh | 38 ++++++++++++++++++++++++++++++++++++++
 transport.c             |  5 ++---
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index ea2ab28..664dd20 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -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;
@@ -232,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, 
NULL);
+       get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL,
+                        &extra_have, &shallow);
 
        transport_verify_remote_names(nr_refspecs, refspecs);
 
diff --git a/t/t5537-push-shallow.sh b/t/t5537-push-shallow.sh
index ff5eb5b..f5c74e6 100755
--- a/t/t5537-push-shallow.sh
+++ b/t/t5537-push-shallow.sh
@@ -82,4 +82,42 @@ EOF
        test_cmp expect actual
 '
 
+test_expect_success 'push from shallow to shallow' '
+       (
+       cd shallow &&
+       git --git-dir=../shallow2/.git config receive.shallowupdate true &&
+       git push ../shallow2/.git +master:refs/remotes/shallow/master &&
+       git --git-dir=../shallow2/.git config receive.shallowupdate false
+       ) &&
+       (
+       cd shallow2 &&
+       git log --format=%s shallow/master >actual &&
+       git fsck &&
+       cat <<EOF >expect &&
+5
+4
+3
+EOF
+       test_cmp expect actual
+       )
+'
+
+test_expect_success 'push from full to shallow' '
+       ! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object 
--stdin` &&
+       commit 1 &&
+       git push shallow2/.git +master:refs/remotes/top/master &&
+       (
+       cd shallow2 &&
+       git log --format=%s top/master >actual &&
+       git fsck &&
+       cat <<EOF >expect &&
+1
+4
+3
+EOF
+       test_cmp expect actual &&
+       git cat-file blob `echo 1|git hash-object --stdin` >/dev/null
+       )
+'
+
 test_done
diff --git a/transport.c b/transport.c
index a09fdb6..d596abb 100644
--- a/transport.c
+++ b/transport.c
@@ -819,11 +819,10 @@ static int git_transport_push(struct transport 
*transport, struct ref *remote_re
                struct ref *tmp_refs;
                connect_setup(transport, 1, 0);
 
-               get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL, 
NULL, NULL);
+               get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL,
+                                NULL, &data->shallow);
                data->got_remote_heads = 1;
        }
-       if (data->shallow.nr)
-               die("pushing to a shallow repository is not supported");
 
        memset(&args, 0, sizeof(args));
        args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);
-- 
1.8.5.1.25.g8667982

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to