google / git-appraise

Distributed code review system for Git repos
Apache License 2.0
5.13k stars 146 forks source link

'Unknown git ref' error frequently occurring #26

Closed hazbo closed 8 years ago

hazbo commented 8 years ago

I'm receiving this error message rather frequently. I don't know in this case if I've been doing something dumb.

All I've done is simply clone git-appraise, pulled down reviews and tried to leave a comment. Upon leaving a comment I receive that particular error message.

/cc @ojarjur

barbastan commented 8 years ago

Interesting. Definitely a question for Omar on his return.

Barbara

On Thu, Dec 24, 2015 at 2:43 AM, Harry Lawrence notifications@github.com wrote:

I'm receiving this error message https://github.com/google/git-appraise/blob/8876cfff2ed848d50cb559c05d44e11b95ca791c/repository/git.go#L171 rather frequently. I don't know in this case if I've been doing something dumb.

All I've done is simply clone git-appraise, pulled down reviews and tried to leave a comment. Upon leaving a comment I receive that particular error message.

/cc @ojarjur https://github.com/ojarjur

— Reply to this email directly or view it on GitHub https://github.com/google/git-appraise/issues/26.

ojarjur commented 8 years ago

I'm pretty sure I know what you are hitting, so let me explain:

Review requests mirrored from a GitHub pull requests wind up with a review ref of the form "refs/pull//head". As such, if you want to do something with one of those reviews, you'll have to fetch that ref locally.

What I've done is add a refspec for fetching from GitHub that makes it recreate the pull refs locally. I.E.:

$ git config --list
....
remote.origin.url=git@github.com:google/git-appraise
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.fetch=+refs/pull/*:refs/pull/*
....

The code tries to be smart about remote refs for branches (so it will accept "refs/remotes/origin/ojarjur/mybranch" as an alternative to "refs/heads/ojarjur/mybranch"), but for pull requests (since they are not branches), the best we can do is just leave it up to the user to fetch them locally.

So, try the following and see if it fixes your issue:

git config --add remote.origin.fetch '+refs/pull/*:refs/pull/*'
hazbo commented 8 years ago

Yeah that seemed to do the trick. Thank you for explaining.