Issue 1752: Command line gerrit review fails when same sha1 is present in more than one project or branch
Status:  Released
Owner: ----
Closed:  Dec 2013
Reported by magnus.reftel, Jan 9, 2013
Affected Version: 2.4.2, but likely all later versions based on the documentation

What steps will reproduce the problem?
1. Create a patch set, noting its commit SHA-1.
2. Create another patch set with a Change-ID in the commit message that is the same as the commit SHA-1 of the patch in step 1 (plus the required leading "I")
3. Run the gerrit review command with the SHA-1 as change specifier (e.g. ssh -p 29418 gerrit.local gerrit review --verified 0 --message '"Autotest passed"' --force-message --project my/project/path 7b722f083757f095efe7d701bbf8249b608eba8d)

What is the expected output? What do you see instead?
The review should end up on the patch set in step 1. Instead, gerrit review aborts the oprtation with the following message:

  fatal: "7b722f083757f095efe7d701bbf8249b608eba8d" matches multiple patch sets

Please provide any additional information below.
There should be an option to the gerrit review command to limit the search to either commits or change IDs.
Jan 30, 2013
Project Member #1 david.pu...@sonymobile.com
I couldn't reproduce this on latest master (2.6-SNAPSHOT).

Looking at the code, it shouldn't match the Change-Id.

It matches on the patterns:

 "^([0-9a-fA-F]{4," + RevId.LEN + "})$"

and

 "^[1-9][0-9]*,[1-9][0-9]*$"

Neither of these will match a Change-Id (sha1 prefixed with 'I').

Apr 24, 2013
#2 presich....@gmail.com
I've reproduced this error. Gerrit version - 2.5.1, 2.5.2

Actually this is not an error - I really have the same SHA-1 in different changes.

But could anyone advise how should I review the change in such case?

Gerrit documentation strongly advises to use SHA-1:
For current backward compatibility with user tools patch sets may also be specified in the legacy CHANGEID,PATCHSET format, such as 8242,2. Support for this legacy format is planned to be removed in a future edition of Gerrit Code Review. Use of commit SHA-1s is strongly encouraged.

Many thanks!
Nov 27, 2013
#3 ocroque...@free.fr
The idea described in the documentation is a bad idea. There are valid scenarios where you have the same SHA1 for 2 different changes, for instance if you want to do the same change on 2 different target branches.
See also: https://groups.google.com/forum/#!topic/repo-discuss/lg5PV7D0ShM


Nov 27, 2013
Project Member #4 david.pu...@sonymobile.com
I have also seen the same problem now.   The problem can also happen if the same commit  sha1 exists in the same branch on more than one change (uploaded under different Change-Id).
Nov 27, 2013
Project Member #5 david.pu...@sonymobile.com
Until the issues are fixed it is better to use the 'change,patchset' format in the review command.

The documentation available now states that this format is legacy and planned to be removed, but since it's not possible to identify a unique patch set without this format, we need to keep it.  The documentation is updated accordingly in [1]

Also, note that the --force-message option that is given in the example command in this issue report, is removed from Gerrit 2.8.


[1] https://gerrit-review.googlesource.com/#/c/52254/

Nov 27, 2013
Project Member #6 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Accepted
Nov 27, 2013
Project Member #7 david.pu...@sonymobile.com
(No comment was entered for this change.)
Summary: Command line gerrit review fails when same sha1 is present in more than one project or branch (was: Command line gerrit review with sha1 mistakenly finds change by change ID)
Dec 3, 2013
Project Member #8 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.9
Jul 18, 2014
Project Member #9 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Released