Skip to content

Commit f54fbf5

Browse files
stefanbellergitster
authored andcommitted
pretty: prepare format_commit_message to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 424510e commit f54fbf5

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

contrib/coccinelle/the_repository.pending.cocci

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,13 @@ expression G;
132132
- logmsg_reencode(
133133
+ repo_logmsg_reencode(the_repository,
134134
E, F, G);
135+
136+
@@
137+
expression E;
138+
expression F;
139+
expression G;
140+
expression H;
141+
@@
142+
- format_commit_message(
143+
+ repo_format_commit_message(the_repository,
144+
E, F, G, H);

pretty.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,9 +1508,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
15081508
strbuf_release(&dummy);
15091509
}
15101510

1511-
void format_commit_message(const struct commit *commit,
1512-
const char *format, struct strbuf *sb,
1513-
const struct pretty_print_context *pretty_ctx)
1511+
void repo_format_commit_message(struct repository *r,
1512+
const struct commit *commit,
1513+
const char *format, struct strbuf *sb,
1514+
const struct pretty_print_context *pretty_ctx)
15141515
{
15151516
struct format_commit_context context;
15161517
const char *output_enc = pretty_ctx->output_encoding;
@@ -1524,9 +1525,9 @@ void format_commit_message(const struct commit *commit,
15241525
* convert a commit message to UTF-8 first
15251526
* as far as 'format_commit_item' assumes it in UTF-8
15261527
*/
1527-
context.message = logmsg_reencode(commit,
1528-
&context.commit_encoding,
1529-
utf8);
1528+
context.message = repo_logmsg_reencode(r, commit,
1529+
&context.commit_encoding,
1530+
utf8);
15301531

15311532
strbuf_expand(sb, format, format_commit_item, &context);
15321533
rewrap_message_tail(sb, &context, 0, 0, 0);
@@ -1550,7 +1551,7 @@ void format_commit_message(const struct commit *commit,
15501551
}
15511552

15521553
free(context.commit_encoding);
1553-
unuse_commit_buffer(commit, context.message);
1554+
repo_unuse_commit_buffer(r, commit, context.message);
15541555
}
15551556

15561557
static void pp_header(struct pretty_print_context *pp,

pretty.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
103103
* Put the result to "sb".
104104
* Please use this function for custom formats.
105105
*/
106-
void format_commit_message(const struct commit *commit,
106+
void repo_format_commit_message(struct repository *r,
107+
const struct commit *commit,
107108
const char *format, struct strbuf *sb,
108109
const struct pretty_print_context *context);
110+
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
111+
#define format_commit_message(c, f, s, con) \
112+
repo_format_commit_message(the_repository, c, f, s, con)
113+
#endif
109114

110115
/*
111116
* Parse given arguments from "arg", check it for correctness and

0 commit comments

Comments
 (0)