summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ed24b6)
raw | patch | inline | side by side (parent: 3ed24b6)
author | Johan Herland <johan@herland.net> | |
Fri, 9 Oct 2009 10:22:04 +0000 (12:22 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 20 Oct 2009 02:00:24 +0000 (19:00 -0700) |
This patch adds the following flags to get_commit_notes() for adjusting the
format of the produced note string:
- NOTES_SHOW_HEADER: Print "Notes:" line before the notes contents
- NOTES_INDENT: Indent notes contents by 4 spaces
Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
format of the produced note string:
- NOTES_SHOW_HEADER: Print "Notes:" line before the notes contents
- NOTES_INDENT: Indent notes contents by 4 spaces
Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c | patch | blob | history | |
notes.h | patch | blob | history | |
pretty.c | patch | blob | history |
index 2b66723f5fe52b4c32830904748679dd62a3cc47..b7d79e19005f3c384e8e52795746bffdb20d6e67 100644 (file)
--- a/notes.c
+++ b/notes.c
}
void get_commit_notes(const struct commit *commit, struct strbuf *sb,
- const char *output_encoding)
+ const char *output_encoding, int flags)
{
static const char utf8[] = "utf-8";
unsigned char *sha1;
if (msglen && msg[msglen - 1] == '\n')
msglen--;
- strbuf_addstr(sb, "\nNotes:\n");
+ if (flags & NOTES_SHOW_HEADER)
+ strbuf_addstr(sb, "\nNotes:\n");
for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) {
linelen = strchrnul(msg_p, '\n') - msg_p;
- strbuf_addstr(sb, " ");
+ if (flags & NOTES_INDENT)
+ strbuf_addstr(sb, " ");
strbuf_add(sb, msg_p, linelen);
strbuf_addch(sb, '\n');
}
index 79d21b65f56d2374aed14e58810d1b7c58fafb8a..7f3eed4384208a6cff16aac08d64a9dfb2dafe57 100644 (file)
--- a/notes.h
+++ b/notes.h
#ifndef NOTES_H
#define NOTES_H
+#define NOTES_SHOW_HEADER 1
+#define NOTES_INDENT 2
+
void get_commit_notes(const struct commit *commit, struct strbuf *sb,
- const char *output_encoding);
+ const char *output_encoding, int flags);
#endif
diff --git a/pretty.c b/pretty.c
index e25db81eaa531b97141c2dc3e9246ff3010924ed..01eadd0482f234e2e89ce1e78dbcb1b3a303278e 100644 (file)
--- a/pretty.c
+++ b/pretty.c
strbuf_addch(sb, '\n');
if (fmt != CMIT_FMT_ONELINE)
- get_commit_notes(commit, sb, encoding);
+ get_commit_notes(commit, sb, encoding,
+ NOTES_SHOW_HEADER | NOTES_INDENT);
free(reencoded);
}