git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 18/24] pretty: prepare format_commit_message to handle arbitrary repositories

From
Stefan Beller <sbeller@google.com>
Date
Oct 30, 2018, 22:08 UTC
Message-ID
<20181030220817.61691-19-sbeller@google.com>
In-Reply-To
<20181030220817.61691-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 contrib/coccinelle/the_repository.pending.cocci | 10 ++++++++++
 pretty.c                                        | 15 ++++++++-------
 pretty.h                                        |  7 ++++++-
 3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
index f5b42cfc62..2ee702ecf7 100644
--- a/contrib/coccinelle/the_repository.pending.cocci
+++ b/contrib/coccinelle/the_repository.pending.cocci
@@ -132,3 +132,13 @@ expression G;
 - logmsg_reencode(
 + repo_logmsg_reencode(the_repository,
   E, F, G);
+
+@@
+expression E;
+expression F;
+expression G;
+expression H;
+@@
+- format_commit_message(
++ repo_format_commit_message(the_repository,
+  E, F, G, H);
diff --git a/pretty.c b/pretty.c
index b359b68750..3240495308 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1508,9 +1508,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)
 	strbuf_release(&dummy);
 }
 
-void format_commit_message(const struct commit *commit,
-			   const char *format, struct strbuf *sb,
-			   const struct pretty_print_context *pretty_ctx)
+void repo_format_commit_message(struct repository *r,
+				const struct commit *commit,
+				const char *format, struct strbuf *sb,
+				const struct pretty_print_context *pretty_ctx)
 {
 	struct format_commit_context context;
 	const char *output_enc = pretty_ctx->output_encoding;
@@ -1524,9 +1525,9 @@ void format_commit_message(const struct commit *commit,
 	 * convert a commit message to UTF-8 first
 	 * as far as 'format_commit_item' assumes it in UTF-8
 	 */
-	context.message = logmsg_reencode(commit,
-					  &context.commit_encoding,
-					  utf8);
+	context.message = repo_logmsg_reencode(r, commit,
+					       &context.commit_encoding,
+					       utf8);
 
 	strbuf_expand(sb, format, format_commit_item, &context);
 	rewrap_message_tail(sb, &context, 0, 0, 0);
@@ -1550,7 +1551,7 @@ void format_commit_message(const struct commit *commit,
 	}
 
 	free(context.commit_encoding);
-	unuse_commit_buffer(commit, context.message);
+	repo_unuse_commit_buffer(r, commit, context.message);
 }
 
 static void pp_header(struct pretty_print_context *pp,
diff --git a/pretty.h b/pretty.h
index 7359d318a9..e6625269cf 100644
--- a/pretty.h
+++ b/pretty.h
@@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
  * Put the result to "sb".
  * Please use this function for custom formats.
  */
-void format_commit_message(const struct commit *commit,
+void repo_format_commit_message(struct repository *r,
+			const struct commit *commit,
 			const char *format, struct strbuf *sb,
 			const struct pretty_print_context *context);
+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
+#define format_commit_message(c, f, s, con) \
+	repo_format_commit_message(the_repository, c, f, s, con)
+#endif
 
 /*
  * Parse given arguments from "arg", check it for correctness and
-- 
2.19.1.930.g4563a0d9d0-goog
Previous: Stefan BellerNext: Stefan Beller
Message 31 of 43 in “[PATCHv2 00/24] Bring more repository handles into our code base]”
  1. Stefan BellerOct 30, 2018
  2. 01/24 Makefile: add pending semantic patchesStefan Beller, Oct 30, 2018
  3. Junio C HamanoOct 31, 2018
  4. Makefile: add pending semantic patchesStefan Beller, Nov 8, 2018
  5. Martin ÅgrenNov 9, 2018
  6. Stefan BellerNov 9, 2018
  7. Junio C HamanoNov 9, 2018
  8. Stefan BellerNov 9, 2018
  9. SZEDER GáborNov 13, 2018
  10. Junio C HamanoNov 14, 2018
  11. coccicheck: introduce 'pending' semantic patchesStefan Beller, Nov 10, 2018
  12. Martin ÅgrenNov 10, 2018
  13. Josh SteadmonNov 12, 2018
  14. SZEDER GáborNov 13, 2018
  15. 02/24 sha1_file: allow read_object to read objects in arbitrary repositoriesStefan Beller, Oct 30, 2018
  16. 03/24 packfile: allow has_packed_and_bad to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  17. 04/24 object-store: allow read_object_file_extended to read from arbitrary repositoriesStefan Beller, Oct 30, 2018
  18. 05/24 object-store: prepare read_object_file to deal with arbitrary repositoriesStefan Beller, Oct 30, 2018
  19. 06/24 object-store: prepare has_{sha1, object}_file[_with_flags] to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  20. 07/24 object: parse_object to honor its repository argumentStefan Beller, Oct 30, 2018
  21. 08/24 commit: allow parse_commit* to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  22. 09/24 commit-reach.c: allow paint_down_to_common to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  23. 10/24 commit-reach.c: allow merge_bases_many to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  24. 11/24 commit-reach.c: allow remove_redundant to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  25. 13/24 commit-reach: prepare get_merge_bases to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  26. 14/24 commit-reach: prepare in_merge_bases[_many] to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  27. 15/24 commit: prepare get_commit_buffer to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  28. 12/24 commit-reach.c: allow get_merge_bases_many_0 to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  29. 16/24 commit: prepare repo_unuse_commit_buffer to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  30. 17/24 commit: prepare logmsg_reencode to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  31. 18/24 pretty: prepare format_commit_message to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  32. 19/24 submodule: use submodule repos for object lookupStefan Beller, Oct 30, 2018
  33. Derrick StoleeNov 2, 2018
  34. Stefan BellerNov 2, 2018
  35. Derrick StoleeNov 2, 2018
  36. 20/24 submodule: don't add submodule as odb for pushStefan Beller, Oct 30, 2018
  37. 21/24 commit-graph: convert remaining function to handle arbitrary repositoriesStefan Beller, Oct 30, 2018
  38. 22/24 commit: make free_commit_buffer and release_commit_memory repository agnosticStefan Beller, Oct 30, 2018
  39. 23/24 path.h: make REPO_GIT_PATH_FUNC repository agnosticStefan Beller, Oct 30, 2018
  40. 24/24 t/helper/test-repository: celebrate independence from the_repositoryStefan Beller, Oct 30, 2018
  41. Junio C HamanoOct 31, 2018
  42. Stefan BellerNov 1, 2018
  43. Junio C HamanoNov 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.