threads / discuss / 21683

Ambiguous ref names

Subject: Ambiguous ref names

## tl;dr

6 messages between Nov 20, 2009 and Dec 11, 2009.

replies: 5people: 2as markdown or json

Jeenu V· Nov 20, 2009, 10:18 UTC · lore
Hi,
I'm re-posting this from the git-users Google Groups:

If I've two branches a.b.c and a.b.c.d, why does 'git checkout' complains about ambiguous ref names? For example, if I'm in a.b.c.d,

896 $ git checkout a.b.c warning: refname 'a.b.c' is ambiguous. Switched to branch "a.b.c"

Is this some kind of a side effect of commit abbreviation? If so is this kind of branch naming considered unsafe? Is there a way to make git accept ref names verbatim, even if there's potential operation that'd fail because of ambiguity?

-- 
:J
Junio C Hamano· Nov 20, 2009, 10:26 UTC · re: Jeenu V · lore

Re: Ambiguous ref names

Jeenu V <jeenuv@gmail.com> writes:
> If I've two branches a.b.c and a.b.c.d, why does 'git checkout'
> complains about ambiguous ref names?
Because it doesn't???
    : demo; git init
    Initialized empty Git repository in /var/tmp/gomi/twelve/.git/
    : demo/master; >f
    : demo/master; git add f
    : demo/master; git commit -a -m 'initial'
    [master (root-commit) cb1d5f2] initial
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 f
    : demo/master; git branch a.b.c
    : demo/master; git branch a.b.c.d
    : demo/master; git checkout a.b.c
    Switched to branch 'a.b.c'

It could be that you have a tag and a branch that are both named a.b.c, though.

Jeenu V· Nov 20, 2009, 10:48 UTC · re: Junio C Hamano · lore

Re: Ambiguous ref names

On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
> [...]
> It could be that you have a tag and a branch that are both named a.b.c,
> though.

Hm, right. But I'm getting this from an existing local repo of mine. I can't see any tags; 'git tag -l' is empty. Is there any more info that I can provide?

FWIW, I'm running Git under Cygwin.
-- 
:J
Junio C Hamano· Nov 20, 2009, 10:59 UTC · re: Jeenu V · lore

Re: Ambiguous ref names

Jeenu V <jeenuv@gmail.com> writes:
Show 8 quoted lines
> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> [...]
>> It could be that you have a tag and a branch that are both named a.b.c,
>> though.
>
> Hm, right. But I'm getting this from an existing local repo of mine. I
> can't see any tags; 'git tag -l' is empty. Is there any more info that
> I can provide?
man git-for-each-ref?
Jeenu V· Nov 20, 2009, 11:55 UTC · re: Junio C Hamano · lore

Re: Ambiguous ref names

On Fri, Nov 20, 2009 at 4:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Jeenu V <jeenuv@gmail.com> writes:
>
>> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> [...]
>>> It could be that you have a tag and a branch that are both named a.b.c,
>>> though.
>>
>> Hm, right. But I'm getting this from an existing local repo of mine. I
>> can't see any tags; 'git tag -l' is empty. Is there any more info that
>> I can provide?
>
> man git-for-each-ref?
It does list all refs that I know of, but I don't see any duplicate entries.
-- 
:J
Jeenu V· Dec 11, 2009, 08:03 UTC · re: Jeenu V · lore

Re: Ambiguous ref names

On Fri, Nov 20, 2009 at 5:25 PM, Jeenu V <jeenuv@gmail.com> wrote:
Show 16 quoted lines
>
> On Fri, Nov 20, 2009 at 4:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Jeenu V <jeenuv@gmail.com> writes:
> >
> >> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
> >>> [...]
> >>> It could be that you have a tag and a branch that are both named a.b.c,
> >>> though.
> >>
> >> Hm, right. But I'm getting this from an existing local repo of mine. I
> >> can't see any tags; 'git tag -l' is empty. Is there any more info that
> >> I can provide?
> >
> > man git-for-each-ref?
>
> It does list all refs that I know of, but I don't see any duplicate entries.

Ah, I think I get what happened here: I had used git update-ref, which turned out to be used wrongly. My intention was to update a.b.c to a new ref, but I used it 'git update-ref XXXXXX', rather than 'git update-ref refs/heads/a.b.c XXXXXX'. The wrong usage created .git/a.b.c and I guess this was causing the warning.

-- :J

← back to recent threads