aboutsummaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-06-11 00:34:54 -0700
committerJunio C Hamano <gitster@pobox.com>2007-06-13 00:41:21 -0700
commit80583c0ef61cc966c7eee79cf3623a83197e19b8 (patch)
tree91afec821a568d3f96ecd3da5c2a80022dc36dda /log-tree.c
parent90ac368afd75c9a53c6d953a693380369a41f8db (diff)
downloadgit-80583c0ef61cc966c7eee79cf3623a83197e19b8.tar.gz
git-80583c0ef61cc966c7eee79cf3623a83197e19b8.tar.xz
Lift 16kB limit of log message output
Traditionally we had 16kB limit when formatting log messages for output, because it was easier to arrange for the caller to have a reasonably big buffer and pass it down without ever worrying about reallocating. This changes the calling convention of pretty_print_commit() to lift this limit. Instead of the buffer and remaining length, it now takes a pointer to the pointer that points at the allocated buffer, and another pointer to the location that stores the allocated length, and reallocates the buffer as necessary. To support the user format, the error return of interpolate() needed to be changed. It used to return a bool telling "Ok the result fits", or "Sorry, I had to truncate it". Now it returns 0 on success, and returns the size of the buffer it wants in order to fit the whole result. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/log-tree.c b/log-tree.c
index 4bef90914..0cf21bc05 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -79,16 +79,25 @@ static int detect_any_signoff(char *letter, int size)
return seen_head && seen_name;
}
-static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
+static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p,
+ unsigned long at, const char *signoff)
{
static const char signed_off_by[] = "Signed-off-by: ";
- int signoff_len = strlen(signoff);
+ size_t signoff_len = strlen(signoff);
int has_signoff = 0;
- char *cp = buf;
-
- /* Do we have enough space to add it? */
- if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 3)
- return at;
+ char *cp;
+ char *buf;
+ unsigned long buf_sz;
+
+ buf = *buf_p;
+ buf_sz = *buf_sz_p;
+ if (buf_sz <= at + strlen(signed_off_by) + signoff_len + 3) {
+ buf_sz += strlen(signed_off_by) + signoff_len + 3;
+ buf = xrealloc(buf, buf_sz);
+ *buf_p = buf;
+ *buf_sz_p = buf_sz;
+ }
+ cp = buf;
/* First see if we already have the sign-off by the signer */
while ((cp = strstr(cp, signed_off_by))) {
@@ -133,7 +142,8 @@ static unsigned int digits_in_number(unsigned int number)
void show_log(struct rev_info *opt, const char *sep)
{
- static char this_header[16384];
+ char *msgbuf = NULL;
+ unsigned long msgbuf_len = 0;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
@@ -278,14 +288,15 @@ void show_log(struct rev_info *opt, const char *sep)
/*
* And then the pretty-printed message itself
*/
- len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header,
- sizeof(this_header), abbrev, subject,
+ len = pretty_print_commit(opt->commit_format, commit, ~0u,
+ &msgbuf, &msgbuf_len, abbrev, subject,
extra_headers, opt->date_mode);
if (opt->add_signoff)
- len = append_signoff(this_header, sizeof(this_header), len,
+ len = append_signoff(&msgbuf, &msgbuf_len, len,
opt->add_signoff);
- printf("%s%s%s", this_header, extra, sep);
+ printf("%s%s%s", msgbuf, extra, sep);
+ free(msgbuf);
}
int log_tree_diff_flush(struct rev_info *opt)