]> git.ipfire.org Git - thirdparty/git.git/commit - wt-status.c
status: fix missing newline when comment chars are disabled
authorJeff King <peff@peff.net>
Thu, 27 Apr 2017 09:01:05 +0000 (05:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Apr 2017 02:40:52 +0000 (11:40 +0900)
commit75177c8591aee23374c2ead9c9505ce989a8eec2
treeebb10a42b2981929e7f0f6c2e95c880dcc0d6cef
parent027a3b943b444a3e3a76f9a89803fc10245b858f
status: fix missing newline when comment chars are disabled

When git-status shows tracking data for the current branch
in the long format, we try to end the stanza with a blank
line. When status.displayCommentPrefix is true, we call
color_fprintf_ln() to do so. But when it's false, we call
the enigmatic:

  fputs("", s->fp);

which does nothing at all! This is a bug from 7d7d68022
(silence a bunch of format-zero-length warnings,
2014-05-04). Prior to that, we called fprintf_ln() with an
empty string. Switching to fputs() meant we needed to
include the "newline in the string, but we didn't.

So you see:

  On branch jk/status-tracking-newline
  Your branch is ahead of 'origin/master' by 1 commit.
  Changes not staged for commit:
          modified:  foo

  Untracked files:
     bar

whereas there should be a blank line before the "Changes not
staged" line.

The fix itself is a one-liner. But we never noticed this
bug because t7508 doesn't exercise the ahead/behind code at
all.  So let's configure an upstream during the initial
setup, which means that the code will be exercised as part
of all of the various invocations in that script. This makes
the diff rather noisy, but should give us good coverage.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7508-status.sh
wt-status.c