cannot open review, "no new changes"

160 views
Skip to first unread message

James Muir

unread,
Aug 17, 2023, 12:11:18 AM8/17/23
to Repo and Gerrit Discussion
Does anyone know why gerrit does not allow a review to be opened when a local branch tracks a remote branch and is up-to-date with it?

For example,

$ git branch -vv
  main             cf3a6643a [origin/main] Fix unit test failure
* jmuir/more-tests 79c278fa8 [origin/jmuir/more-tests] more unit tests
$ git push origin HEAD:refs/for/main
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, done    
To ssh://gerrit.example.com/foo
 ! [remote rejected]     HEAD -> refs/for/main (no new changes)
error: failed to push some refs to 'ssh://gerrit.example.com/foo'

I can work around this by updating my local branch using "git commit --amend" so that it is no longer up-to-date with the remote branch.  In that case, gerrit allows the review to be created.

-James M

James Muir

unread,
Aug 17, 2023, 11:09:25 AM8/17/23
to Repo and Gerrit Discussion
On Thu, Aug 17, 2023 at 12:11 AM James Muir <jm...@crypto4a.com> wrote:
Does anyone know why gerrit does not allow a review to be opened when a local branch tracks a remote branch and is up-to-date with it?



gerrit does not allow the review to be opened because that *commit* already exists upstream.

The fact that the commit is not on the target branch doesn't matter (to gerrit).

Sven Selberg

unread,
Aug 18, 2023, 2:35:27 AM8/18/23
to Repo and Gerrit Discussion
If this is a use-case that you want to support you can set receive.createNewChangeForAllNotInTarget in project.config.

- Sven

 
Message has been deleted

James Muir

unread,
Aug 18, 2023, 9:10:44 AM8/18/23
to Repo and Gerrit Discussion
Thanks very much for letting me know about that option.

I tried setting it in the gerrit 3.8.1 ui; i.e. I set "Create a new change for every commit not in the target branch" to true in the relevant project.

Initially, I thought the option was not working, but it appears I was hitting a defect in git-review:

$ git branch -vv
* jmuir/foo    b570abc [origin/jmuir/foo] even more foo
  master       72bef46 [origin/master] more foo, more testing
$ git review -r origin master
No changes between HEAD and origin/master. Submitting for review would
be pointless.
$ git review -r origin --no-track master
No changes between HEAD and origin/master. Submitting for review would
be pointless.
$ git push origin HEAD:refs/for/master
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Processing changes: refs: 1, new: 1, done    
remote:
remote: SUCCESS
remote:
remote:   https://gerrit.example.com/c/jm-test/+/184 even more foo [NEW]
remote:
 * [new reference]   HEAD -> refs/for/master

git-review must be doing its own check somehow.

-James M


Reply all
Reply to author
Forward
0 new messages