On Tue, Apr 15, 2008 at 11:48:23PM -0400, Jeff King wrote: > ISTR some discussion in the past few months about using the type of > <branch1> to guess the type of <branch2>, but it seems not to have gone > anywhere. > > Daniel, were you working on this? Hmm. Here is a quick patch I worked up, but it causes t5516:14 (push with ambiguity) to fail. However, I'm not sure the test is right: it looks like it's trying to find ambiguity between remotes/origin/master and remotes/frotz/master, but in fact matches _neither_ of them. So it was failing before as we expected, but for the wrong reason. --- remote.c | 23 +++++++++++++++++++---- t/t5516-fetch-push.sh | 8 ++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/remote.c b/remote.c index 08af7f9..2f5d062 100644 --- a/remote.c +++ b/remote.c @@ -851,10 +851,25 @@ 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 - error("dst refspec %s does not match any " - "existing ref on the remote and does " - "not start with refs/.", dst_value); + else { + /* + * We don't have a full ref name for the dst and + * it doesn't exist, so let's assume it's the same + * type as our src. + */ + struct strbuf tmp = STRBUF_INIT; + const char *c; + int slashes; + for (c = matched_src->name, slashes = 0; + *c && slashes < 2; c++) { + strbuf_addch(&tmp, *c); + if (*c == '/') + slashes++; + } + strbuf_addstr(&tmp, dst_value); + dst_value = strbuf_detach(&tmp, NULL); + matched_dst = make_linked_ref(dst_value, dst_tail); + } break; default: matched_dst = NULL; diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 793ffc6..370f79a 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -285,6 +285,14 @@ test_expect_success 'push with colon-less refspec (4)' ' ' +test_expect_success 'push with non-existant, incomplete dest' ' + + mk_test && + git push testrepo master:brandnewbranch && + check_push_result $the_commit heads/brandnewbranch + +' + test_expect_success 'push with HEAD' ' mk_test heads/master && -- 1.5.5.64.geecd2.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html