pretty_print_commit(): pass commit object instead of commit->buffer.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
62a604ba1c
commit
3815f423ae
3
commit.c
3
commit.c
@ -456,12 +456,13 @@ static int add_parent_info(enum cmit_fmt fmt, char *buf, const char *line, int p
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long pretty_print_commit(enum cmit_fmt fmt, const char *msg, unsigned long len, char *buf, unsigned long space, int abbrev)
|
unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, unsigned long len, char *buf, unsigned long space, int abbrev)
|
||||||
{
|
{
|
||||||
int hdr = 1, body = 0;
|
int hdr = 1, body = 0;
|
||||||
unsigned long offset = 0;
|
unsigned long offset = 0;
|
||||||
int parents = 0;
|
int parents = 0;
|
||||||
int indent = (fmt == CMIT_FMT_ONELINE) ? 0 : 4;
|
int indent = (fmt == CMIT_FMT_ONELINE) ? 0 : 4;
|
||||||
|
const char *msg = commit->buffer;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const char *line = msg;
|
const char *line = msg;
|
||||||
|
2
commit.h
2
commit.h
@ -48,7 +48,7 @@ enum cmit_fmt {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern enum cmit_fmt get_commit_format(const char *arg);
|
extern enum cmit_fmt get_commit_format(const char *arg);
|
||||||
extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const char *msg, unsigned long len, char *buf, unsigned long space, int abbrev);
|
extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev);
|
||||||
|
|
||||||
/** Removes the first commit from a list sorted by date, and adds all
|
/** Removes the first commit from a list sorted by date, and adds all
|
||||||
* of its parents.
|
* of its parents.
|
||||||
|
11
diff-tree.c
11
diff-tree.c
@ -64,12 +64,13 @@ static int diff_root_tree(const unsigned char *new, const char *base)
|
|||||||
|
|
||||||
static const char *generate_header(const unsigned char *commit_sha1,
|
static const char *generate_header(const unsigned char *commit_sha1,
|
||||||
const unsigned char *parent_sha1,
|
const unsigned char *parent_sha1,
|
||||||
const char *msg)
|
const struct commit *commit)
|
||||||
{
|
{
|
||||||
static char this_header[16384];
|
static char this_header[16384];
|
||||||
int offset;
|
int offset;
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
int abbrev = diff_options.abbrev;
|
int abbrev = diff_options.abbrev;
|
||||||
|
const char *msg = commit->buffer;
|
||||||
|
|
||||||
if (!verbose_header)
|
if (!verbose_header)
|
||||||
return sha1_to_hex(commit_sha1);
|
return sha1_to_hex(commit_sha1);
|
||||||
@ -82,7 +83,7 @@ static const char *generate_header(const unsigned char *commit_sha1,
|
|||||||
offset += sprintf(this_header + offset, "(from %s)\n",
|
offset += sprintf(this_header + offset, "(from %s)\n",
|
||||||
parent_sha1 ?
|
parent_sha1 ?
|
||||||
diff_unique_abbrev(parent_sha1, abbrev) : "root");
|
diff_unique_abbrev(parent_sha1, abbrev) : "root");
|
||||||
offset += pretty_print_commit(commit_format, msg, len,
|
offset += pretty_print_commit(commit_format, commit, len,
|
||||||
this_header + offset,
|
this_header + offset,
|
||||||
sizeof(this_header) - offset, abbrev);
|
sizeof(this_header) - offset, abbrev);
|
||||||
return this_header;
|
return this_header;
|
||||||
@ -103,7 +104,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
|
|||||||
|
|
||||||
/* Root commit? */
|
/* Root commit? */
|
||||||
if (show_root_diff && !commit->parents) {
|
if (show_root_diff && !commit->parents) {
|
||||||
header = generate_header(sha1, NULL, commit->buffer);
|
header = generate_header(sha1, NULL, commit);
|
||||||
diff_root_tree(commit_sha1, "");
|
diff_root_tree(commit_sha1, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,9 +114,7 @@ static int diff_tree_commit(const unsigned char *commit_sha1)
|
|||||||
|
|
||||||
for (parents = commit->parents; parents; parents = parents->next) {
|
for (parents = commit->parents; parents; parents = parents->next) {
|
||||||
struct commit *parent = parents->item;
|
struct commit *parent = parents->item;
|
||||||
header = generate_header(sha1,
|
header = generate_header(sha1, parent->object.sha1, commit);
|
||||||
parent->object.sha1,
|
|
||||||
commit->buffer);
|
|
||||||
diff_tree_sha1_top(parent->object.sha1, commit_sha1, "");
|
diff_tree_sha1_top(parent->object.sha1, commit_sha1, "");
|
||||||
if (!header && verbose_header) {
|
if (!header && verbose_header) {
|
||||||
header_prefix = "\ndiff-tree ";
|
header_prefix = "\ndiff-tree ";
|
||||||
|
@ -81,7 +81,7 @@ static void show_commit(struct commit *commit)
|
|||||||
|
|
||||||
if (verbose_header) {
|
if (verbose_header) {
|
||||||
static char pretty_header[16384];
|
static char pretty_header[16384];
|
||||||
pretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header), 0);
|
pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), 0);
|
||||||
printf("%s%c", pretty_header, hdr_termination);
|
printf("%s%c", pretty_header, hdr_termination);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -258,7 +258,7 @@ static void show_one_commit(struct commit *commit, int no_name)
|
|||||||
char pretty[256], *cp;
|
char pretty[256], *cp;
|
||||||
struct commit_name *name = commit->object.util;
|
struct commit_name *name = commit->object.util;
|
||||||
if (commit->object.parsed)
|
if (commit->object.parsed)
|
||||||
pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
|
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
|
||||||
pretty, sizeof(pretty), 0);
|
pretty, sizeof(pretty), 0);
|
||||||
else
|
else
|
||||||
strcpy(pretty, "(unavailable)");
|
strcpy(pretty, "(unavailable)");
|
||||||
|
Loading…
Reference in New Issue
Block a user