Issue 1430: Restore change is broken
Status:  Released
Owner: ----
Closed:  Jun 2012
Reported by cco3@android.com, Jun 7, 2012
Broken in master.

Restoring via ssh complains that refs/heads/master doesn't exist.  The restore button doesn't even show up in the web-ui.

Specifically, ProjectUtil.branchExists(repoManager, change.getDest()) is returning false when it shouldn't be.

I determined that the following was the offending change:
https://gerrit-review.googlesource.com/#/c/35831/

Even though I double checked several times that I was building that commit, I really don't trust myself since it looks harmless and the change right after it looks much more suspect:
https://gerrit-review.googlesource.com/#/c/35832/
Jun 11, 2012
Project Member #1 edwin.ke...@gmail.com
Are there any special steps needed to reproduce this problem? For me restoring changes via web UI and SSH is working fine with current master.
Jun 12, 2012
#2 cco3@android.com
There were no special steps.  Maybe it's been fixed somehow?  I'll try to reproduce again.
Jun 12, 2012
#3 cco3@android.com
It still does not work for me.  However, If I build on commits that were merged in before https://gerrit-review.googlesource.com/#/c/35832/ everything works fine.  There's nothing in the error log (because as I said, it's just that method returning false, or rather repoManager within that method does not find the branch).  Is there any other information I can give you?
Jun 12, 2012
#4 cco3@android.com
To be clear, the commands I run are as follows:

tools/release.sh
java -jar gerrit-war/target/gerrit-*.war init -d /tmp/test_review_site < /dev/null
cat /tmp/test_review_site/logs/error_log
cat ~/.ssh/id_rsa.pub
# add my ssh key, add a username, etc
ssh -p 29418 cco3@localhost gerrit create-project --name blah.git
git clone ssh://cco3@localhost:29418/blah
cd blah
git commit --allow-empty -mstart
git push ssh://cco3@localhost:29418/blah HEAD:refs/for/master
cd -
rm -rf blah
# Abandon the change through either the web ui or ssh
# Notice that restore button is missing
Jun 12, 2012
#5 cco3@android.com
FYI, I tried reverting both of those changes from master and it doesn't fix the issue for me.
Jun 13, 2012
Project Member #6 edwin.ke...@gmail.com
Thanks for providing the commands, now it's clear to me why you are seeing this issue. In your setup you create a completely empty repository without any commits and branches (without using the --empty-commit option).
So in this case the central master branch does really not exist. Pushing to master is only possible because there is a special handling in ReceiveCommits (line 824 - 828) that allows pushing to the branch to which HEAD points even if it does not exist yet. I think we should apply the same logic in ProjectUtil.branchExists(...) so that restore works again for changes that were abandoned for an empty repository.

I've pushed a fix for review [1]. Can you please try it?

[1] https://gerrit-review.googlesource.com/35971
Jun 13, 2012
#7 sop@google.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.5
Jun 13, 2012
#8 cco3@android.com
Thanks guys!  Not sure how I ended up on those suspect commits...I guess I accidentally said "good" or "bad" incorrectly when using `git bisect`.
Oct 31, 2012
Project Member #9 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Released