git-send-email: Do not make @-less message ID
[gitweb.git] / remote.c
index 120df36be002b543e609060b8f318fe7b38d437c..500ca4d968753485ac38d44e238e93ab86372c1c 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -455,7 +455,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
                errs = 1;
 
        if (dst_value == NULL)
-               dst_value = rs->src;
+               dst_value = matched_src->name;
 
        switch (count_refspec_match(dst_value, dst, &matched_dst)) {
        case 1:
@@ -463,11 +463,6 @@ static int match_explicit(struct ref *src, struct ref *dst,
        case 0:
                if (!memcmp(dst_value, "refs/", 5))
                        matched_dst = make_dst(dst_value, dst_tail);
-               else if (!strcmp(rs->src, dst_value) && matched_src)
-                       /* pushing "master:master" when
-                        * remote does not have master yet.
-                        */
-                       matched_dst = make_dst(matched_src->name, dst_tail);
                else
                        error("dst refspec %s does not match any "
                              "existing ref on the remote and does "
@@ -551,13 +546,14 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
                }
 
                if (pat) {
-                       dst_name = xmalloc(strlen(pat->dst) +
+                       const char *dst_side = pat->dst ? pat->dst : pat->src;
+                       dst_name = xmalloc(strlen(dst_side) +
                                           strlen(src->name) -
                                           strlen(pat->src) + 2);
-                       strcpy(dst_name, pat->dst);
+                       strcpy(dst_name, dst_side);
                        strcat(dst_name, src->name + strlen(pat->src));
                } else
-                       dst_name = strdup(src->name);
+                       dst_name = xstrdup(src->name);
                dst_peer = find_ref_by_name(dst, dst_name);
                if (dst_peer && dst_peer->peer_ref)
                        /* We're already sending something to this ref. */