From 22a3d060937072b0f197a8084af879c753c68fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 13 Jan 2009 20:57:16 +0100 Subject: git-notes: fix printing of multi-line notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The line length was read from the same position every time, causing mangled output when printing notes with multiple lines. Also, adding new-line manually for each line ensures that we get a new-line between commits, matching git-log for commits without notes. Signed-off-by: Tor Arne Vestbø Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- notes.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'notes.c') diff --git a/notes.c b/notes.c index ad43a2ed1..bd737842d 100644 --- a/notes.c +++ b/notes.c @@ -110,8 +110,8 @@ void get_commit_notes(const struct commit *commit, struct strbuf *sb, { static const char *utf8 = "utf-8"; unsigned char *sha1; - char *msg; - unsigned long msgoffset, msglen; + char *msg, *msg_p; + unsigned long linelen, msglen; enum object_type type; if (!initialized) { @@ -148,12 +148,13 @@ void get_commit_notes(const struct commit *commit, struct strbuf *sb, strbuf_addstr(sb, "\nNotes:\n"); - for (msgoffset = 0; msgoffset < msglen;) { - int linelen = strchrnul(msg, '\n') - msg; + for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) { + linelen = strchrnul(msg_p, '\n') - msg_p; strbuf_addstr(sb, " "); - strbuf_add(sb, msg + msgoffset, linelen); - msgoffset += linelen; + strbuf_add(sb, msg_p, linelen); + strbuf_addch(sb, '\n'); } + free(msg); } -- cgit v1.2.1