send-pack: support pushing to a shallow clone
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0a1bc12b6e
commit
b016918b2f
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user