0

Following comments to this answer and information if Gerrit's docs. If adding proper refs is mandatory:

git push gerrit HEAD:refs/for/master

Then why Gerrit is accepting at all a push without them? After doing git push origin master with proper refs missing, push is accpeted (at Git level), but no change is created (at Gerrit level). User is ending up with a mess in code review system (can't merge non-existing change, can't push nothing else, because he or she is getting no changes reject) and must do a lot of strange things to fix this problem.

What is the reason or logic for implementing a feature, that such commit will be accepted? Why Gerrit isn't rejecting pushes, that it can't handle at all?

Community
  • 1
  • 1
trejder
  • 17,148
  • 27
  • 124
  • 216

2 Answers2

1

you can create a push rule in Gerrit Administration page, where you can disable the direct push. see the details here in my team it is useful to have two groups with different push rules. The groups working on the same branch, but only one of the group introduced the Gerrit workflow. But that does not mean that the commit or changes would cause a mess because of pushed in different way to remote barnch. Gerrit/Git will handle it by rejecting non-fastforward changes.

laplasz
  • 3,359
  • 1
  • 29
  • 40
  • If I'm getting docs mentioned by you right, direct push will bypass all the code review mechanism. That is not, what I'm willing to achieve. – trejder Dec 16 '13 at 10:53
  • I don't know, what do you mean by saying, that commit wouldn't cause the mess. The facts are described in my question. Gerrit has accepted my push, though it has no bloody idea, what to do with it. It did not created change corresponding to commit in that push and (details in [linked question](http://stackoverflow.com/q/20542903/1469208)) it doesn't also accepted any further pushes / commits, making a real mess. At least for me. – trejder Dec 16 '13 at 10:55
  • 1
    I think you have problem only at branch creation. first create the local branch without any new changes i.e.`git checkout -b origin/master` then the remote: `git push origin ` or via the Gerrit UI. After that everything should be fine. – laplasz Dec 16 '13 at 11:00
1

If a user has sufficient permissions (specifically a Push permission that covers the refs in question, in this case refs/heads/master), s/he can bypass reviews by pushing changes straight into the branch. This is very much by design and is necessary for common tasks like importing upstream commits. In many cases this action is restricted to administrators, project maintainers, and similar power users in order to enforce reviews, but I'm sure some organizations use Gerrit for optional code reviews. Gerrit should be regarded as a general purpose Git server that supports code reviews.

If you don't want this behavior then you should adjust the access rights of your gits.

Magnus Bäck
  • 11,381
  • 3
  • 47
  • 59