On Thu, Mar 12, 2009 at 04:40:10PM +0000, Pieter de Bie wrote: >> I think the future-proofing is probably not worth the effort. >> Catching things that are ambiguous _now_ will cover the "oops, I >> typed the wrong thing" case, which I think is really the issue. > > Exactly, that's the common case where things go wrong. I guess using > dwim_ref should be DWIM enough? :) Hmm. Yeah, I mispoke before: I should have said dwim_ref instead of resolve_ref (which doesn't dwym :) ). Here's a sloppy patch that I think does what you want; but it might make more sense to just iterate over ref_rev_parse_rules ourselves, as dwim_ref does more than we care about (and we should probably differentiate between "a branch already exists" and "this would make an ambiguous ref"). --- diff --git a/branch.c b/branch.c index d20fb04..409f445 100644 --- a/branch.c +++ b/branch.c @@ -122,6 +122,7 @@ void create_branch(const char *head, unsigned char sha1[20]; char *real_ref, msg[PATH_MAX + 20]; struct strbuf ref = STRBUF_INIT; + char *junk; int forcing = 0; int len; @@ -135,7 +136,8 @@ void create_branch(const char *head, if (check_ref_format(ref.buf)) die("'%s' is not a valid branch name.", name); - if (resolve_ref(ref.buf, sha1, 1, NULL)) { + if (dwim_ref(name, strlen(name), sha1, &junk)) { + free(junk); if (!force) die("A branch named '%s' already exists.", name); else if (!is_bare_repository() && !strcmp(head, name)) -- 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