pretty_print_commit(): pass commit object instead of commit->buffer.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 27, 2006 at 01:54 UTC
3815f423ae39bf774de3c268c6d3e3b72128a4e5
5 files changed
+10
-10
commit.c
+2
-1
@@ -456,12 +456,13 @@ static int add_parent_info(enum cmit_fmt fmt, char *buf, const char *line, int p
456
return offset;
457
}
458
459
-unsigned long pretty_print_commit(enum cmit_fmt fmt, const char *msg, unsigned long len, char *buf, unsigned long space, int abbrev)
459
+unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, unsigned long len, char *buf, unsigned long space, int abbrev)
460
{
461
int hdr = 1, body = 0;
462
unsigned long offset = 0;
463
int parents = 0;
464
int indent = (fmt == CMIT_FMT_ONELINE) ? 0 : 4;
465
+ const char *msg = commit->buffer;
466
467
for (;;) {
468
const char *line = msg;
commit.h
+1
-1
@@ -48,7 +48,7 @@ enum cmit_fmt {
48
};
49
50
extern enum cmit_fmt get_commit_format(const char *arg);
51
-extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const char *msg, unsigned long len, char *buf, unsigned long space, int abbrev);
51
+extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev);
52
53
/** Removes the first commit from a list sorted by date, and adds all
54
* of its parents.
diff-tree.c
+5
-6
@@ -64,12 +64,13 @@ static int diff_root_tree(const unsigned char *new, const char *base)
64
65
static const char *generate_header(const unsigned char *commit_sha1,
66
const unsigned char *parent_sha1,
67
- const char *msg)
67
+ const struct commit *commit)
68
{
69
static char this_header[16384];
70
int offset;
71
unsigned long len;
72
int abbrev = diff_options.abbrev;
73
+ const char *msg = commit->buffer;
74
75
if (!verbose_header)
76
return sha1_to_hex(commit_sha1);
@@ -82,7 +83,7 @@ static const char *generate_header(const unsigned char *commit_sha1,
83
offset += sprintf(this_header + offset, "(from %s)\n",
84
parent_sha1 ?
85
diff_unique_abbrev(parent_sha1, abbrev) : "root");
85
- offset += pretty_print_commit(commit_format, msg, len,
86
+ offset += pretty_print_commit(commit_format, commit, len,
87
this_header + offset,
88
sizeof(this_header) - offset, abbrev);
89
return this_header;
@@ -103,7 +104,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
104
105
/* Root commit? */
106
if (show_root_diff && !commit->parents) {
106
- header = generate_header(sha1, NULL, commit->buffer);
107
+ header = generate_header(sha1, NULL, commit);
108
diff_root_tree(commit_sha1, "");
109
}
110
@@ -113,9 +114,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
114
115
for (parents = commit->parents; parents; parents = parents->next) {
116
struct commit *parent = parents->item;
116
- header = generate_header(sha1,
117
- parent->object.sha1,
118
- commit->buffer);
117
+ header = generate_header(sha1, parent->object.sha1, commit);
118
diff_tree_sha1_top(parent->object.sha1, commit_sha1, "");
119
if (!header && verbose_header) {
120
header_prefix = "\ndiff-tree ";
rev-list.c
+1
-1
@@ -81,7 +81,7 @@ static void show_commit(struct commit *commit)
81
82
if (verbose_header) {
83
static char pretty_header[16384];
84
- pretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header), 0);
84
+ pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), 0);
85
printf("%s%c", pretty_header, hdr_termination);
86
}
87
fflush(stdout);
show-branch.c
+1
-1
@@ -258,7 +258,7 @@ static void show_one_commit(struct commit *commit, int no_name)
258
char pretty[256], *cp;
259
struct commit_name *name = commit->object.util;
260
if (commit->object.parsed)
261
- pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
261
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
262
pretty, sizeof(pretty), 0);
263
else
264
strcpy(pretty, "(unavailable)");