Export format_commit_message()
Drop the parameter "msg" of format_commit_message() (as it can be inferred from the parameter "commit"), add a parameter "template" in order to avoid accessing the static variable user_format directly and export the result. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ren,bi(B Scharfe committed
Sep 3, 2007 at 20:06 UTC
7b95089c0f59a25bb1c506b6962eb64412c585eb
2 files changed
+6
-4
commit.c
+5
-4
@@ -787,8 +787,8 @@ static void fill_person(struct interp *table, const char *msg, int len)
787
interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));
788
}
789
790
-static long format_commit_message(const struct commit *commit,
791
- const char *msg, char **buf_p, unsigned long *space_p)
790
+long format_commit_message(const struct commit *commit, const void *format,
791
+ char **buf_p, unsigned long *space_p)
792
{
793
struct interp table[] = {
794
{ "%H" }, /* commit hash */
@@ -843,6 +843,7 @@ static long format_commit_message(const struct commit *commit,
843
char parents[1024];
844
int i;
845
enum { HEADER, SUBJECT, BODY } state;
846
+ const char *msg = commit->buffer;
847
848
if (ILEFT_RIGHT + 1 != ARRAY_SIZE(table))
849
die("invalid interp table!");
@@ -924,7 +925,7 @@ static long format_commit_message(const struct commit *commit,
925
char *buf = *buf_p;
926
unsigned long space = *space_p;
927
927
- space = interpolate(buf, space, user_format,
928
+ space = interpolate(buf, space, format,
929
table, ARRAY_SIZE(table));
930
if (!space)
931
break;
@@ -1165,7 +1166,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
1166
char *buf;
1167
1168
if (fmt == CMIT_FMT_USERFORMAT)
1168
- return format_commit_message(commit, msg, buf_p, space_p);
1169
+ return format_commit_message(commit, user_format, buf_p, space_p);
1170
1171
encoding = (git_log_output_encoding
1172
? git_log_output_encoding
commit.h
+1
@@ -61,6 +61,7 @@ enum cmit_fmt {
61
};
62
63
extern enum cmit_fmt get_commit_format(const char *arg);
64
+extern long format_commit_message(const struct commit *commit, const void *template, char **buf_p, unsigned long *space_p);
65
extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode);
66
67
/** Removes the first commit from a list sorted by date, and adds all