Merge branch 'cc/starts-n-ends-with-endgame'
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Mar 2014 23:18:17 +0000 (15:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Mar 2014 23:18:28 +0000 (15:18 -0800)
prefixcmp/suffixcmp are gone.

1  2 
builtin/push.c
git-compat-util.h
diff --cc builtin/push.c
index cd6c1646a5fa4009664f5c96a38d7c8df3fcd467,7b1b66c36ac14cb29db9dbbbd5b6f4d27b67d91c..f8dfea41e1ad8b6d888c1a2adc13eee87083491e
@@@ -34,49 -35,9 +34,49 @@@ static void add_refspec(const char *ref
        refspec[refspec_nr-1] = ref;
  }
  
 -static void set_refspecs(const char **refs, int nr)
 +static const char *map_refspec(const char *ref,
 +                             struct remote *remote, struct ref *local_refs)
  {
-           !prefixcmp(matched->name, "refs/heads/")) {
 +      struct ref *matched = NULL;
 +
 +      /* Does "ref" uniquely name our ref? */
 +      if (count_refspec_match(ref, local_refs, &matched) != 1)
 +              return ref;
 +
 +      if (remote->push) {
 +              struct refspec query;
 +              memset(&query, 0, sizeof(struct refspec));
 +              query.src = matched->name;
 +              if (!query_refspecs(remote->push, remote->push_refspec_nr, &query) &&
 +                  query.dst) {
 +                      struct strbuf buf = STRBUF_INIT;
 +                      strbuf_addf(&buf, "%s%s:%s",
 +                                  query.force ? "+" : "",
 +                                  query.src, query.dst);
 +                      return strbuf_detach(&buf, NULL);
 +              }
 +      }
 +
 +      if (push_default == PUSH_DEFAULT_UPSTREAM &&
++          starts_with(matched->name, "refs/heads/")) {
 +              struct branch *branch = branch_get(matched->name + 11);
 +              if (branch->merge_nr == 1 && branch->merge[0]->src) {
 +                      struct strbuf buf = STRBUF_INIT;
 +                      strbuf_addf(&buf, "%s:%s",
 +                                  ref, branch->merge[0]->src);
 +                      return strbuf_detach(&buf, NULL);
 +              }
 +      }
 +
 +      return ref;
 +}
 +
 +static void set_refspecs(const char **refs, int nr, const char *repo)
 +{
 +      struct remote *remote = NULL;
 +      struct ref *local_refs = NULL;
        int i;
 +
        for (i = 0; i < nr; i++) {
                const char *ref = refs[i];
                if (!strcmp("tag", ref)) {
Simple merge