diff options
author | Philip Kelley <phkelley@hotmail.com> | 2012-11-21 14:29:52 -0500 |
---|---|---|
committer | Philip Kelley <phkelley@hotmail.com> | 2012-11-21 14:29:52 -0500 |
commit | 18778a50bea269cc8c795dcd01905e3dac38138a (patch) | |
tree | 79245e1529ad67c19175d408c6a2e9c3c3209964 | |
parent | e3ff4394eb1586b181349f778c07c97474087ed0 (diff) | |
download | libgit2-18778a50bea269cc8c795dcd01905e3dac38138a.tar.gz |
More fixes for push; remove one of the push tests
-rw-r--r-- | src/push.c | 5 | ||||
-rw-r--r-- | src/transports/smart_protocol.c | 10 | ||||
-rw-r--r-- | tests-clar/network/push.c | 24 |
3 files changed, 12 insertions, 27 deletions
diff --git a/src/push.c b/src/push.c index 0831cbd75..3cb9718b1 100644 --- a/src/push.c +++ b/src/push.c @@ -182,11 +182,14 @@ static int revwalk(git_vector *commits, git_push *push) error = git_merge_base(&base, push->repo, &spec->loid, &spec->roid); - if (error == GIT_ENOTFOUND) { + + if (error == GIT_ENOTFOUND || + (!error && !git_oid_equal(&base, &spec->roid))) { giterr_clear(); error = GIT_ENONFASTFORWARD; goto on_error; } + if (error < 0) goto on_error; } diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index a2cd0f9d0..cb88f5058 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -677,8 +677,14 @@ int git_smart__push(git_transport *transport, git_push *push) if (git_smart__get_push_stream(t, &s) < 0 || gen_pktline(&pktline, push) < 0 || s->write(s, git_buf_cstr(&pktline), git_buf_len(&pktline)) < 0 || - git_packbuilder_foreach(push->pb, &stream_thunk, s) < 0 || - (push->report_status && parse_report(&t->buffer, push) < 0)) + git_packbuilder_foreach(push->pb, &stream_thunk, s) < 0) + goto on_error; + + /* If we sent nothing or the server doesn't support report-status, then + * we consider the pack to have been unpacked successfully */ + if (!push->specs.length || !push->report_status) + push->unpack_ok = 1; + else if (parse_report(&t->buffer, push) < 0) goto on_error; error = 0; diff --git a/tests-clar/network/push.c b/tests-clar/network/push.c index 00087e8ab..b8965c067 100644 --- a/tests-clar/network/push.c +++ b/tests-clar/network/push.c @@ -378,30 +378,6 @@ void test_network_push__implicit_tgt(void) exp_refs2, ARRAY_SIZE(exp_refs2), 0); } -void test_network_push__implicit_all(void) -{ - const char *specs[] = { ":" }; - push_status exp_stats[] = { - { "refs/heads/b1", NULL }, - { "refs/heads/b2", NULL }, - { "refs/heads/b3", NULL }, - { "refs/heads/b4", NULL }, - { "refs/heads/b5", NULL }, - { "refs/heads/master", NULL } - }; - expected_ref exp_refs[] = { - { "refs/heads/b1", &_oid_b1 }, - { "refs/heads/b2", &_oid_b2 }, - { "refs/heads/b3", &_oid_b3 }, - { "refs/heads/b4", &_oid_b4 }, - { "refs/heads/b5", &_oid_b5 }, - { "refs/heads/master", &_oid_master } - }; - do_push(specs, ARRAY_SIZE(specs), - exp_stats, ARRAY_SIZE(exp_stats), - exp_refs, ARRAY_SIZE(exp_refs), 0); -} - void test_network_push__fast_fwd(void) { /* Fast forward b1 in tgt from _oid_b1 to _oid_master. */ |