From: Junio C Hamano Date: Fri, 7 Mar 2014 23:18:17 +0000 (-0800) Subject: Merge branch 'cc/starts-n-ends-with-endgame' X-Git-Tag: v2.0.0-rc0~136 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e3f118594683b075d70fb479a81613f614a7b1f1?ds=inline;hp=--cc Merge branch 'cc/starts-n-ends-with-endgame' prefixcmp/suffixcmp are gone. --- e3f118594683b075d70fb479a81613f614a7b1f1 diff --cc builtin/push.c index cd6c1646a5,7b1b66c36a..f8dfea41e1 --- a/builtin/push.c +++ b/builtin/push.c @@@ -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) { + 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 && - !prefixcmp(matched->name, "refs/heads/")) { ++ 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)) {