| Issue 1396: | Submodule Subscription updates contain rogue "null" string | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Affected Version: 2.4-rc0
What steps will reproduce the problem?
1. Setup a .gitmodule subscription in a project (Super.git, referencing Sub.git)
2. Create a change in Sub.git, submit the change. Example commit message "Updating sub\n\nChange-Id: I..."
3. Notice that Super.git has its submodule automatically updated, but the commit message contains a rogue "null" in the message.
What is the expected output?
Updated Super.git
Project: Sub.git abc123...
Updating sub
Change-Id: I...
Reviewed-on: http://gerrit/..
(etc)
What do you see instead?
Updated Super.git
Project: Sub.git abc123...
null
Updating sub
Change-Id: I...
Reviewed-on: http://gerrit/..
(etc)
note the "null" string between the "Project: " line, and the Sub.git commit message.
Please provide any additional information below.
Looking at the code, the issue is here, starting at line 203 of SubmoduleOp.java:
String msgbuf = msg;
if (msgbuf == null) {
// (snip Large comment here)
// ...
for (final Change chg : submitted) {
final CodeReviewCommit c = commits.get(chg.getId());
if (c != null
&& (c.statusCode == CommitMergeStatus.CLEAN_MERGE || c.statusCode == CommitMergeStatus.CLEAN_PICK)) {
msgbuf += "\n";
// ...
At line 204, we know that msgbuf is null. Then it is never initialized, but on line 218, a newline is appended. Since msgbuf was already null, the concatenation operator automatically casts null to a string, to give the string literal "null", and then the newline is appended after that.
The fix is to initialize msgbuf to an empty string inside this if block at line 205.
I will submit a patch to fix this and follow up with the review.
May 18, 2012
#1
jhans...@myyearbook.com
May 19, 2012
Submitted on master as Change-Id: I07a4b071fabbb0b4a28403603884cb05d777c01b.
Status:
Submitted
Labels: FixedIn-2.5
Oct 31, 2012
(No comment was entered for this change.)
Status:
Released
|
|
| ► Sign in to add a comment |