Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

ResolveRevision doesn't resolve ambigious revs #823

Open
ZJvandeWeg opened this issue May 7, 2018 · 6 comments
Open

ResolveRevision doesn't resolve ambigious revs #823

ZJvandeWeg opened this issue May 7, 2018 · 6 comments

Comments

@ZJvandeWeg
Copy link
Contributor

When a branch has the same name as the SHA of the commit it depends on, ResolveRevision() doesn't correctly resolve it.

I'm not sure how users get in this situation, but to reproduce:

$ git init
$ touch file && git add . && git commit -m "init commit"
$ git checkout -b $(git rev-parse HEAD)
@ZJvandeWeg
Copy link
Contributor Author

Seems like it should be supported through #706, I'll take another look later this week.

@mcuadros
Copy link
Contributor

@antham can you please take a look?

@antham
Copy link
Contributor

antham commented Oct 15, 2018

yes

@antham
Copy link
Contributor

antham commented Oct 15, 2018

In this case you get a warning like this when you do a rev-parse

warning: refname 'c75323d86168af6202ec4b314b249c78a62b0a8c' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,

  git checkout -b $br $(git rev-parse ...)

where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config advice.objectNameWarning false"

so what I've done in this case is to return an error.

@antham
Copy link
Contributor

antham commented Oct 16, 2018

@mcuadros

@antham
Copy link
Contributor

antham commented Oct 20, 2018

@mcuadros ?

novas0x2a added a commit to novas0x2a/go-git that referenced this issue May 14, 2019
1) lookups on an annotated tag oid now work
2) there was a lot of complexity around detection of ambiguity, but
   unlike git, ambiguous refs are rejected (which causes bugs like
   src-d#823). The new code matches rev-parse's behavior (prefer the OID),
   though there is no warning path to report the same warning.
novas0x2a added a commit to novas0x2a/go-git that referenced this issue May 14, 2019
1) lookups on an annotated tag oid now work
2) there was a lot of complexity around detection of ambiguity, but
   unlike git, ambiguous refs are rejected (which causes bugs like
   src-d#823). The new code matches rev-parse's behavior (prefer the OID),
   though there is no warning path to report the same warning.

Signed-off-by: Mike Lundy <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants