Git development
 help / color / mirror / Atom feed
From: Johan Herland <johan@herland.net>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines
Date: Thu, 25 Sep 2008 01:10:54 +0200	[thread overview]
Message-ID: <200809250110.54229.johan@herland.net> (raw)

'git for-each-ref --format=%(subject)' currently returns an empty string
if the log message does not contain a newline.

This patch teaches 'git for-each-ref' to return the entire log message
(instead of an empty string) if there is no newline in the log message.

Signed-off-by: Johan Herland <johan@herland.net>
---

Normally, log messages in git have trailing newlines. However, it seems the
"tag fixup commits" manufactured by cvs2svn/cvs2git (via git-fast-import)
have single-line log message without trailing newlines.

I have checked the other callers of copy_line(), and AFAICS they are not
affected by this change, since that would violate the git object format.


Have fun! :)

...Johan


 builtin-for-each-ref.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 9b44092..e59bd80 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -321,8 +321,8 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
 static const char *copy_line(const char *buf)
 {
 	const char *eol = strchr(buf, '\n');
-	if (!eol)
-		return "";
+	if (!eol) // simulate strchrnul()
+		eol = buf + strlen(buf);
 	return xmemdupz(buf, eol - buf);
 }
 
-- 
1.6.0.2.463.g7f0eb

             reply	other threads:[~2008-09-24 23:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 23:10 Johan Herland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-09-27 22:08 [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines Nanako Shiraishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200809250110.54229.johan@herland.net \
    --to=johan@herland.net \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox