Always trim Change-Id lines to handle non-standard whitespace
A user might copy-and-paste a Change-Id line from the little info table on the web, which usually brings in a tab rather than a space between the tag and the identity. So we would see [1] instead of seeing the more typical string [2]. [1] "Change-Id:\tIdeadbeef...\n" [2] "Change-Id: Ideadbeef...\n". Prior to this bug fix we were trimming during insertion of a new change into the database, but we did not trim when querying to look for replacement or merge candidates. This could lead the same Change-Id showing up twice in the database. Change-Id: Ia90b894eda545abf0b976b1610ae68bb4147d963 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
e529c0fab7
commit
1a9029b006
|
@ -722,7 +722,8 @@ final class Receive extends AbstractGitCommand {
|
|||
|
||||
final List<String> idList = c.getFooterLines(CHANGE_ID);
|
||||
if (!idList.isEmpty()) {
|
||||
final Change.Key key = new Change.Key(idList.get(idList.size() - 1));
|
||||
final String idStr = idList.get(idList.size() - 1).trim();
|
||||
final Change.Key key = new Change.Key(idStr);
|
||||
final List<Change> changes =
|
||||
db.changes().byProjectKey(project.getNameKey(), key).toList();
|
||||
if (changes.size() > 1) {
|
||||
|
@ -1275,7 +1276,7 @@ final class Receive extends AbstractGitCommand {
|
|||
|
||||
rw.parseBody(c);
|
||||
for (final String changeId : c.getFooterLines(CHANGE_ID)) {
|
||||
final Change.Id onto = byKey.get(new Change.Key(changeId));
|
||||
final Change.Id onto = byKey.get(new Change.Key(changeId.trim()));
|
||||
if (onto != null) {
|
||||
toClose.add(new ReplaceRequest(onto, c, cmd));
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue