Skip to content

Commit 3815f42

Browse files
author
Junio C Hamano
committed
pretty_print_commit(): pass commit object instead of commit->buffer.
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 62a604b commit 3815f42

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

commit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,13 @@ static int add_parent_info(enum cmit_fmt fmt, char *buf, const char *line, int p
456456
return offset;
457457
}
458458

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)
460460
{
461461
int hdr = 1, body = 0;
462462
unsigned long offset = 0;
463463
int parents = 0;
464464
int indent = (fmt == CMIT_FMT_ONELINE) ? 0 : 4;
465+
const char *msg = commit->buffer;
465466

466467
for (;;) {
467468
const char *line = msg;

commit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum cmit_fmt {
4848
};
4949

5050
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);
5252

5353
/** Removes the first commit from a list sorted by date, and adds all
5454
* of its parents.

diff-tree.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ static int diff_root_tree(const unsigned char *new, const char *base)
6464

6565
static const char *generate_header(const unsigned char *commit_sha1,
6666
const unsigned char *parent_sha1,
67-
const char *msg)
67+
const struct commit *commit)
6868
{
6969
static char this_header[16384];
7070
int offset;
7171
unsigned long len;
7272
int abbrev = diff_options.abbrev;
73+
const char *msg = commit->buffer;
7374

7475
if (!verbose_header)
7576
return sha1_to_hex(commit_sha1);
@@ -82,7 +83,7 @@ static const char *generate_header(const unsigned char *commit_sha1,
8283
offset += sprintf(this_header + offset, "(from %s)\n",
8384
parent_sha1 ?
8485
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,
8687
this_header + offset,
8788
sizeof(this_header) - offset, abbrev);
8889
return this_header;
@@ -103,7 +104,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
103104

104105
/* Root commit? */
105106
if (show_root_diff && !commit->parents) {
106-
header = generate_header(sha1, NULL, commit->buffer);
107+
header = generate_header(sha1, NULL, commit);
107108
diff_root_tree(commit_sha1, "");
108109
}
109110

@@ -113,9 +114,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
113114

114115
for (parents = commit->parents; parents; parents = parents->next) {
115116
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);
119118
diff_tree_sha1_top(parent->object.sha1, commit_sha1, "");
120119
if (!header && verbose_header) {
121120
header_prefix = "\ndiff-tree ";

rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void show_commit(struct commit *commit)
8181

8282
if (verbose_header) {
8383
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);
8585
printf("%s%c", pretty_header, hdr_termination);
8686
}
8787
fflush(stdout);

show-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void show_one_commit(struct commit *commit, int no_name)
258258
char pretty[256], *cp;
259259
struct commit_name *name = commit->object.util;
260260
if (commit->object.parsed)
261-
pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
261+
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
262262
pretty, sizeof(pretty), 0);
263263
else
264264
strcpy(pretty, "(unavailable)");

0 commit comments

Comments
 (0)