Skip to content

Commit 424510e

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

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

commit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text);
180180
extern const char *logmsg_reencode(const struct commit *commit,
181181
char **commit_encoding,
182182
const char *output_encoding);
183+
const char *repo_logmsg_reencode(struct repository *r,
184+
const struct commit *commit,
185+
char **commit_encoding,
186+
const char *output_encoding);
187+
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
188+
#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)
189+
#endif
190+
183191
extern const char *skip_blank_lines(const char *msg);
184192

185193
/** Removes the first commit from a list sorted by date, and adds all

contrib/coccinelle/the_repository.pending.cocci

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,12 @@ expression F;
123123
- unuse_commit_buffer(
124124
+ repo_unuse_commit_buffer(the_repository,
125125
E, F);
126+
127+
@@
128+
expression E;
129+
expression F;
130+
expression G;
131+
@@
132+
- logmsg_reencode(
133+
+ repo_logmsg_reencode(the_repository,
134+
E, F, G);

pretty.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding)
595595
return strbuf_detach(&tmp, NULL);
596596
}
597597

598-
const char *logmsg_reencode(const struct commit *commit,
599-
char **commit_encoding,
600-
const char *output_encoding)
598+
const char *repo_logmsg_reencode(struct repository *r,
599+
const struct commit *commit,
600+
char **commit_encoding,
601+
const char *output_encoding)
601602
{
602603
static const char *utf8 = "UTF-8";
603604
const char *use_encoding;
604605
char *encoding;
605-
const char *msg = get_commit_buffer(commit, NULL);
606+
const char *msg = repo_get_commit_buffer(r, commit, NULL);
606607
char *out;
607608

608609
if (!output_encoding || !*output_encoding) {
@@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit,
630631
* the cached copy from get_commit_buffer, we need to duplicate it
631632
* to avoid munging the cached copy.
632633
*/
633-
if (msg == get_cached_commit_buffer(the_repository, commit, NULL))
634+
if (msg == get_cached_commit_buffer(r, commit, NULL))
634635
out = xstrdup(msg);
635636
else
636637
out = (char *)msg;
@@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit,
644645
*/
645646
out = reencode_string(msg, output_encoding, use_encoding);
646647
if (out)
647-
unuse_commit_buffer(commit, msg);
648+
repo_unuse_commit_buffer(r, commit, msg);
648649
}
649650

650651
/*

0 commit comments

Comments
 (0)