diff options
| author | Junio C Hamano <gitster@pobox.com> | 2008-04-24 22:40:02 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2008-04-24 22:40:02 -0700 |
| commit | 049a226fa14fb25c03d2146c2f8f184cfea5e5bf (patch) | |
| tree | f67e46f678cc570a21852e17268afff0ae2120cc /remote.c | |
| parent | 57cf5ca3058b4086744f59f1f520a15dfc040bbb (diff) | |
| parent | 1ce89cc4bb18b0e66f7073562d6634f6a9841335 (diff) | |
| download | git-049a226fa14fb25c03d2146c2f8f184cfea5e5bf.tar.gz | |
Merge branch 'maint'
* maint:
remote: create fetch config lines with '+'
push: allow unqualified dest refspecs to DWIM
doc/git-gc: add a note about what is collected
t5516: remove ambiguity test (1)
Linked glossary from cvs-migration page
write-tree: properly detect failure to write tree objects
Diffstat (limited to 'remote.c')
| -rw-r--r-- | remote.c | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -812,6 +812,26 @@ static struct ref *make_linked_ref(const char *name, struct ref ***tail) return ret; } +static char *guess_ref(const char *name, struct ref *peer) +{ + struct strbuf buf = STRBUF_INIT; + unsigned char sha1[20]; + + const char *r = resolve_ref(peer->name, sha1, 1, NULL); + if (!r) + return NULL; + + if (!prefixcmp(r, "refs/heads/")) + strbuf_addstr(&buf, "refs/heads/"); + else if (!prefixcmp(r, "refs/tags/")) + strbuf_addstr(&buf, "refs/tags/"); + else + return NULL; + + strbuf_addstr(&buf, name); + return strbuf_detach(&buf, NULL); +} + static int match_explicit(struct ref *src, struct ref *dst, struct ref ***dst_tail, struct refspec *rs, @@ -820,6 +840,7 @@ static int match_explicit(struct ref *src, struct ref *dst, struct ref *matched_src, *matched_dst; const char *dst_value = rs->dst; + char *dst_guess; if (rs->pattern) return errs; @@ -866,10 +887,15 @@ static int match_explicit(struct ref *src, struct ref *dst, case 0: if (!memcmp(dst_value, "refs/", 5)) matched_dst = make_linked_ref(dst_value, dst_tail); + else if((dst_guess = guess_ref(dst_value, matched_src))) + matched_dst = make_linked_ref(dst_guess, dst_tail); else - error("dst refspec %s does not match any " - "existing ref on the remote and does " - "not start with refs/.", dst_value); + error("unable to push to unqualified destination: %s\n" + "The destination refspec neither matches an " + "existing ref on the remote nor\n" + "begins with refs/, and we are unable to " + "guess a prefix based on the source ref.", + dst_value); break; default: matched_dst = NULL; |
