{"thread":{"id":"9764","subject":"[PATCH 1/3] Export format_commit_message()","startedAt":"2007-09-03T18:06:36Z","lastAt":"2007-09-03T18:44:10Z","messageCount":3,"participants":["René Scharfe","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"52368","messageId":"46DC4D2C.8070109@lsrfire.ath.cx","threadId":"9764","inReplyTo":null,"subject":"[PATCH 1/3] Export format_commit_message()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2007-09-03T18:06:36Z","receivedAt":"2007-09-03T18:06:36Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Drop the parameter \"msg\" of format_commit_message() (as it can be\ninferred from the parameter \"commit\"), add a parameter \"template\"\nin order to avoid accessing the static variable user_format\ndirectly and export the result.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n commit.c |    9 +++++----\n commit.h |    1 +\n 2 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex dc5a064..651e904 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -787,8 +787,8 @@ static void fill_person(struct interp *table, const char *msg, int len)\n \tinterp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));\n }\n \n-static long format_commit_message(const struct commit *commit,\n-\t\tconst char *msg, char **buf_p, unsigned long *space_p)\n+long format_commit_message(const struct commit *commit, const void *template,\n+                           char **buf_p, unsigned long *space_p)\n {\n \tstruct interp table[] = {\n \t\t{ \"%H\" },\t/* commit hash */\n@@ -843,6 +843,7 @@ static long format_commit_message(const struct commit *commit,\n \tchar parents[1024];\n \tint i;\n \tenum { HEADER, SUBJECT, BODY } state;\n+\tconst char *msg = commit->buffer;\n \n \tif (ILEFT_RIGHT + 1 != ARRAY_SIZE(table))\n \t\tdie(\"invalid interp table!\");\n@@ -924,7 +925,7 @@ static long format_commit_message(const struct commit *commit,\n \t\tchar *buf = *buf_p;\n \t\tunsigned long space = *space_p;\n \n-\t\tspace = interpolate(buf, space, user_format,\n+\t\tspace = interpolate(buf, space, template,\n \t\t\t\t    table, ARRAY_SIZE(table));\n \t\tif (!space)\n \t\t\tbreak;\n@@ -1165,7 +1166,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,\n \tchar *buf;\n \n \tif (fmt == CMIT_FMT_USERFORMAT)\n-\t\treturn format_commit_message(commit, msg, buf_p, space_p);\n+\t\treturn format_commit_message(commit, user_format, buf_p, space_p);\n \n \tencoding = (git_log_output_encoding\n \t\t    ? git_log_output_encoding\ndiff --git a/commit.h b/commit.h\nindex 467872e..a8d7661 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -61,6 +61,7 @@ enum cmit_fmt {\n };\n \n extern enum cmit_fmt get_commit_format(const char *arg);\n+extern long format_commit_message(const struct commit *commit, const void *template, char **buf_p, unsigned long *space_p);\n 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);\n \n /** Removes the first commit from a list sorted by date, and adds all\n-- \n1.5.3\n"},{"id":"52371","messageId":"Pine.LNX.4.64.0709031934480.28586@racer.site","threadId":"9764","inReplyTo":"46DC4D2C.8070109@lsrfire.ath.cx","subject":"Re: [PATCH 1/3] Export format_commit_message()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-03T18:35:44Z","receivedAt":"2007-09-03T18:35:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 3 Sep 2007, Ren? Scharfe wrote:\n\n> -static long format_commit_message(const struct commit *commit,\n> -\t\tconst char *msg, char **buf_p, unsigned long *space_p)\n> +long format_commit_message(const struct commit *commit, const void *template,\n> +                           char **buf_p, unsigned long *space_p)\n\nI am quite sure that this breaks compilation in C++.\n\nBesides, \"format\" is so much more descriptive here IMHO.  What is so wrong \nwith \"format\" for you?\n\nCiao,\nDscho\n"},{"id":"52373","messageId":"46DC55FA.6040905@lsrfire.ath.cx","threadId":"9764","inReplyTo":"Pine.LNX.4.64.0709031934480.28586@racer.site","subject":"Re: [PATCH 1/3] Export format_commit_message()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2007-09-03T18:44:10Z","receivedAt":"2007-09-03T18:44:10Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Johannes Schindelin schrieb:\n>> -static long format_commit_message(const struct commit *commit,\n>> -\t\tconst char *msg, char **buf_p, unsigned long *space_p)\n>> +long format_commit_message(const struct commit *commit, const void *template,\n>> +                           char **buf_p, unsigned long *space_p)\n> \n> I am quite sure that this breaks compilation in C++.\n> \n> Besides, \"format\" is so much more descriptive here IMHO.  What is so wrong \n> with \"format\" for you?\n\nI have nothing against naming the parameter \"format\", actually.  This\nname simply didn't occur to me -- weird but true. :-]\n\nRené\n"}]}