Issue 1396: Submodule Subscription updates contain rogue "null" string
Status:  Released
Owner: ----
Closed:  May 2012
Reported by jhans...@myyearbook.com, May 18, 2012
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 19, 2012
#2 sop@google.com
Submitted on master as Change-Id: I07a4b071fabbb0b4a28403603884cb05d777c01b.
Status: Submitted
Labels: FixedIn-2.5
Oct 31, 2012
Project Member #3 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Released