* [PATCH 1/3] Export format_commit_message()
@ 2007-09-03 18:06 René Scharfe
2007-09-03 18:35 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2007-09-03 18:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
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>
---
commit.c | 9 +++++----
commit.h | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/commit.c b/commit.c
index dc5a064..651e904 100644
--- a/commit.c
+++ b/commit.c
@@ -787,8 +787,8 @@ static void fill_person(struct interp *table, const char *msg, int len)
interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));
}
-static long format_commit_message(const struct commit *commit,
- const char *msg, char **buf_p, unsigned long *space_p)
+long format_commit_message(const struct commit *commit, const void *template,
+ char **buf_p, unsigned long *space_p)
{
struct interp table[] = {
{ "%H" }, /* commit hash */
@@ -843,6 +843,7 @@ static long format_commit_message(const struct commit *commit,
char parents[1024];
int i;
enum { HEADER, SUBJECT, BODY } state;
+ const char *msg = commit->buffer;
if (ILEFT_RIGHT + 1 != ARRAY_SIZE(table))
die("invalid interp table!");
@@ -924,7 +925,7 @@ static long format_commit_message(const struct commit *commit,
char *buf = *buf_p;
unsigned long space = *space_p;
- space = interpolate(buf, space, user_format,
+ space = interpolate(buf, space, template,
table, ARRAY_SIZE(table));
if (!space)
break;
@@ -1165,7 +1166,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
char *buf;
if (fmt == CMIT_FMT_USERFORMAT)
- return format_commit_message(commit, msg, buf_p, space_p);
+ return format_commit_message(commit, user_format, buf_p, space_p);
encoding = (git_log_output_encoding
? git_log_output_encoding
diff --git a/commit.h b/commit.h
index 467872e..a8d7661 100644
--- a/commit.h
+++ b/commit.h
@@ -61,6 +61,7 @@ enum cmit_fmt {
};
extern enum cmit_fmt get_commit_format(const char *arg);
+extern long format_commit_message(const struct commit *commit, const void *template, char **buf_p, unsigned long *space_p);
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);
/** Removes the first commit from a list sorted by date, and adds all
--
1.5.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] Export format_commit_message()
2007-09-03 18:06 [PATCH 1/3] Export format_commit_message() René Scharfe
@ 2007-09-03 18:35 ` Johannes Schindelin
2007-09-03 18:44 ` René Scharfe
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2007-09-03 18:35 UTC (permalink / raw)
To: René Scharfe; +Cc: Junio C Hamano, Git Mailing List
Hi,
On Mon, 3 Sep 2007, Ren? Scharfe wrote:
> -static long format_commit_message(const struct commit *commit,
> - const char *msg, char **buf_p, unsigned long *space_p)
> +long format_commit_message(const struct commit *commit, const void *template,
> + char **buf_p, unsigned long *space_p)
I am quite sure that this breaks compilation in C++.
Besides, "format" is so much more descriptive here IMHO. What is so wrong
with "format" for you?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] Export format_commit_message()
2007-09-03 18:35 ` Johannes Schindelin
@ 2007-09-03 18:44 ` René Scharfe
0 siblings, 0 replies; 3+ messages in thread
From: René Scharfe @ 2007-09-03 18:44 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, Git Mailing List
Johannes Schindelin schrieb:
>> -static long format_commit_message(const struct commit *commit,
>> - const char *msg, char **buf_p, unsigned long *space_p)
>> +long format_commit_message(const struct commit *commit, const void *template,
>> + char **buf_p, unsigned long *space_p)
>
> I am quite sure that this breaks compilation in C++.
>
> Besides, "format" is so much more descriptive here IMHO. What is so wrong
> with "format" for you?
I have nothing against naming the parameter "format", actually. This
name simply didn't occur to me -- weird but true. :-]
René
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-03 18:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-03 18:06 [PATCH 1/3] Export format_commit_message() René Scharfe
2007-09-03 18:35 ` Johannes Schindelin
2007-09-03 18:44 ` René Scharfe
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).