summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorTor Arne Vestbø <tavestbo@trolltech.com>2009-01-13 20:57:16 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-14 14:54:41 -0800
commit22a3d060937072b0f197a8084af879c753c68fe7 (patch)
tree9675025a5567dd28d27b4bdad0ccf8320a085cc9 /notes.c
parentbb1dff9def343a7d513eea8f4eaa5fd7d5d3fc5f (diff)
downloadgit-22a3d060937072b0f197a8084af879c753c68fe7.tar.gz
git-notes: fix printing of multi-line notes
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ø <tavestbo@trolltech.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/notes.c b/notes.c
index ad43a2ed15..bd737842d9 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);
}