summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2012-11-23 13:11:55 -0500
committerPhilip Kelley <phkelley@hotmail.com>2012-11-23 13:11:55 -0500
commit9162da406547f38bd9495cc045883435e11a3283 (patch)
tree56ac1dfb1c2f27bd7edc8b814f64a0c432611c50
parenta7e7f08adf3d6171ebd407c467154a84f0e6ccd7 (diff)
downloadlibgit2-9162da406547f38bd9495cc045883435e11a3283.tar.gz
Strip capabilities^{} after caps detect
-rw-r--r--src/transports/smart.c11
-rw-r--r--tests-clar/network/push.c9
-rw-r--r--tests-clar/network/push_util.c12
3 files changed, 12 insertions, 20 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 51bdd94f6..b6ee8d942 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -69,6 +69,7 @@ static int git_smart__connect(
git_smart_subtransport_stream *stream;
int error;
git_pkt *pkt;
+ git_pkt_ref *first;
git_smart_service_t service;
if (git_smart__reset_stream(t, true) < 0)
@@ -119,9 +120,17 @@ static int git_smart__connect(
/* We now have loaded the refs. */
t->have_refs = 1;
- if (git_smart__detect_caps((git_pkt_ref *)git_vector_get(&t->refs, 0), &t->caps) < 0)
+ first = (git_pkt_ref *)git_vector_get(&t->refs, 0);
+
+ /* Detect capabilities */
+ if (git_smart__detect_caps(first, &t->caps) < 0)
return -1;
+ /* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */
+ if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") &&
+ git_oid_iszero(&first->head.oid))
+ git_vector_clear(&t->refs);
+
if (t->rpc && git_smart__reset_stream(t, false) < 0)
return -1;
diff --git a/tests-clar/network/push.c b/tests-clar/network/push.c
index 19e3ee226..883542836 100644
--- a/tests-clar/network/push.c
+++ b/tests-clar/network/push.c
@@ -121,13 +121,8 @@ static void verify_refs(git_remote *remote, expected_ref expected_refs[], size_t
/* git_push_finish() disconnects the remote. */
cl_assert(!git_remote_connected(remote));
- /* Verify cached refs are correct immediately after git_push_finish()*/
- /*TODO: they are not correct because git_push_finish doesn't update them! What to do?
- git_remote_ls(remote, record_ref_cb, &actual_refs);
- do_verify_remote_refs(&actual_refs, expected_refs, expected_refs_len);
- git_vector_clear(&actual_refs);
-*/
- /* Reconnect to the remote to verify that cached refs were same as current refs*/
+
+ /* Reconnect to the remote to verify the refs */
cl_git_pass(git_remote_connect(remote, GIT_DIR_PUSH));
git_remote_ls(remote, record_ref_cb, &actual_refs);
diff --git a/tests-clar/network/push_util.c b/tests-clar/network/push_util.c
index a18058fc1..e9dbfaafa 100644
--- a/tests-clar/network/push_util.c
+++ b/tests-clar/network/push_util.c
@@ -70,23 +70,11 @@ int record_ref_cb(git_remote_head *head, void *payload)
void verify_remote_refs(git_vector *actual_refs, const expected_ref expected_refs[], size_t expected_refs_len)
{
- /* If there are no refs on the remote, git returns capabilities in a dummy
- * ref pkt-line.
- */
- static const expected_ref no_refs_result[] = { { "capabilities^{}", &OID_ZERO } };
-
size_t i;
-
git_buf msg = GIT_BUF_INIT;
git_remote_head *actual;
char *oid_str;
- if (expected_refs_len == 0) {
- /* Special case when no refs exist on remote. */
- expected_refs = no_refs_result;
- expected_refs_len = ARRAY_SIZE(no_refs_result);
- }
-
if (expected_refs_len != actual_refs->length)
goto failed;