summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da196b6)
raw | patch | inline | side by side (parent: da196b6)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sat, 21 May 2005 18:04:19 +0000 (11:04 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sat, 21 May 2005 18:04:19 +0000 (11:04 -0700) |
Make the commit explanation buffer larger, and make sure that if
we truncate it, we put a "..." marker there to visually tell people
about the truncation (tested with a much smaller buffer to make
sure it looks sane).
Also make sure that the explanation is properly line-terminated,
and add an extra newline iff we have a diff.
we truncate it, we put a "..." marker there to visually tell people
about the truncation (tested with a much smaller buffer to make
sure it looks sane).
Also make sure that the explanation is properly line-terminated,
and add an extra newline iff we have a diff.
diff-tree.c | patch | blob | history |
diff --git a/diff-tree.c b/diff-tree.c
index 233a25066818b49c94112f6f2680c6f6d7c881f8..868404f7c4003f162b16585f1e8db904b8ed4551 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
static char *generate_header(const char *commit, const char *parent, const char *msg, unsigned long len)
{
- static char this_header[1000];
+ static char this_header[16384];
int offset;
offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
@@ -345,8 +345,16 @@ static char *generate_header(const char *commit, const char *parent, const char
if (!linelen)
break;
- if (offset + linelen + 10 > sizeof(this_header))
+
+ /*
+ * We want some slop for indentation and a possible
+ * final "...". Thus the "+ 20".
+ */
+ if (offset + linelen + 20 > sizeof(this_header)) {
+ memcpy(this_header + offset, " ...\n", 8);
+ offset += 8;
break;
+ }
msg += linelen;
len -= linelen;
@@ -361,7 +369,12 @@ static char *generate_header(const char *commit, const char *parent, const char
memcpy(this_header + offset + 4, line, linelen);
offset += linelen + 4;
}
- this_header[offset++] = '\n';
+ /* Make sure there is an EOLN */
+ if (this_header[offset-1] != '\n')
+ this_header[offset++] = '\n';
+ /* Add _another_ EOLN if we are doing diff output */
+ if (!silent)
+ this_header[offset++] = '\n';
this_header[offset] = 0;
}