Fix ref_newer() in send-pack.
[gitweb.git] / connect.c
index d913f296d3a153c377e88da10be46caed136d35d..3953a1af3d321091d53a1381ded0be1abb4d9deb 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -169,7 +169,7 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
                                /* pushing "master:master" when
                                 * remote does not have master yet.
                                 */
-                               int len = strlen(matched_src->name);
+                               int len = strlen(matched_src->name) + 1;
                                matched_dst = xcalloc(1, sizeof(*dst) + len);
                                memcpy(matched_dst->name, matched_src->name,
                                       len);
@@ -230,11 +230,9 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
                if (src->peer_ref)
                        continue;
                dst_peer = find_ref_by_name(dst, src->name);
-               if (dst_peer && dst_peer->peer_ref)
+               if ((dst_peer && dst_peer->peer_ref) || (!dst_peer && !all))
                        continue;
                if (!dst_peer) {
-                       if (!all)
-                               continue;
                        /* Create a new one and link it */
                        int len = strlen(src->name) + 1;
                        dst_peer = xcalloc(1, sizeof(*dst_peer) + len);