Community
Participate
Working Groups
When "Push to Gerrit" command is used but instead of the Gerrit URI, the GIT is selected, the branch called "refs/for/master" is created in the remote repository and all pushes to Gerrit stop working.
I think this should be prevented on server side by installing a pre-receive hook, this way also pushes from other git implementations to this magic ref will be rejected Contact webmaster@eclipse.org if you want this for a git repository hosted at Eclipse the hook may look like (completely untested): #! /bin/sh # reject push to Gerrit magic refs "refs/for/<branch name>" which is not # understood by plain git while read old new longref; do case $longref in refs/for/*) echo "push to $longref rejected You pushed to a plain bare git repository using a Gerrit magic ref which isn't supported by plain git Push to https://git.eclipse.org/r if you want to use Gerrit Code Review at Eclipse" exit 1 esac done for details about pre-receive hooks see section "pre-receive" in [1] [1] https://git-scm.com/docs/githooks
Why doesn't EGit check that the server used for "Push to Gerrit" is in fact Gerrit?
Currently we only check if the server is a Gerrit server when cloning a repository to avoid sending additional requests to the server. When the user cloned using EGit it should auto-detect if the server is a gerrit server and configure the clone correctly so that push to gerrit again goes to Gerrit. From there in order to push to git (and not Gerrit) the user has to manually change the git config of the clone. Why would a user want to do that ? Maybe I miss some use case ...
(In reply to Matthias Sohn from comment #3) The repository was cloned from Git, not Gerrit. Gerrit URI was added later. EGit should be able to determine that the Git server was not Gerrit when cloning from it, shouldn't it?
yes This explains why it didn't work like you expected: - when cloning a repository EGit checks if the server is Gerrit - if yes it configures EGit for Gerrit by setting the option gerrit.createchangeid = true in .git/config - though it does not persist the server's URL If we would in addition also persist the Gerrit URL we could detect that the user pushes to refs/for using a URL which we don't know yet. Then we could again check if this new URL is also a Gerrit server (a project could use multiple Gerrit instances like we do e.g. for our internal fork of Gerrit). If not we could reject push to refs/for or at least raise a warning
New Gerrit change created: https://git.eclipse.org/r/70827
Gerrit change https://git.eclipse.org/r/70827 was merged to [master]. Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=34b9ae2577af951a0d2b683229501fafa24e2b08
(In reply to Eclipse Genie from comment #7) > Gerrit change https://git.eclipse.org/r/70827 was merged to [master]. > Commit: > http://git.eclipse.org/c/egit/egit.git/commit/ > ?id=34b9ae2577af951a0d2b683229501fafa24e2b08 With this change submitted EGit will only push URLs in the "Push to Gerrit" command which are configured to use one of the Gerrit magic refs. So the plain Git URL from your example should no longer be shown in this wizard. You can try this using latest nightly build from http://download.eclipse.org/egit/updates-nightly
Please see possible regression bug 493352.
> Please see possible regression bug 493352. And more damage in bug 501102.