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

[PATCH 1/4] convert: pass 'repo' to the working tree conversion functions

From
AGAniket Gupta <aniketgupta3001@gmail.com>
Date
Oct 24, 2026, 22:00 UTC
Message-ID
<20261024220012.486-2-aniketgupta3001@gmail.com>
In-Reply-To
<20261024220012.486-1-aniketgupta3001@gmail.com>

The functions that convert a blob to its working tree format take a 'struct conv_attrs' but no repository, even though what they do depends on configuration such as 'core.autocrlf' and 'core.eol'. As we migrate these configuration variables into the repository struct, the functions need access to the repository context.

Add a 'struct repository *' parameter to convert_to_working_tree_ca(), async_convert_to_working_tree_ca() and get_stream_filter_ca(), and update all callers to pass the appropriate repository instance. The parameter is not used yet, so mark it as UNUSED for now.

The convert_to_working_tree() and async_convert_to_working_tree() wrappers were static inline functions in 'convert.h'. They need to get the repository from the index, which 'convert.h' does not know about, so move them into 'convert.c'.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 convert.c           | 39 +++++++++++++++++++++++++++++++++++----
 convert.h           | 38 ++++++++++++++++----------------------
 entry.c             | 16 +++++++++++-----
 parallel-checkout.c |  8 +++++---
 4 files changed, 67 insertions(+), 34 deletions(-)
diff --git a/convert.c b/convert.c
index 036506842c..95bdfafdd0 100644
--- a/convert.c
+++ b/convert.c
@@ -1520,7 +1520,8 @@ static int convert_to_working_tree_ca_internal(const struct conv_attrs *ca,
 	return ret | ret_filter;
 }
 
-int async_convert_to_working_tree_ca(const struct conv_attrs *ca,
+int async_convert_to_working_tree_ca(struct repository *repo UNUSED,
+				     const struct conv_attrs *ca,
 				     const char *path, const char *src,
 				     size_t len, struct strbuf *dst,
 				     const struct checkout_metadata *meta,
@@ -1530,7 +1531,8 @@ int async_convert_to_working_tree_ca(const struct conv_attrs *ca,
 						   meta, dco);
 }
 
-int convert_to_working_tree_ca(const struct conv_attrs *ca,
+int convert_to_working_tree_ca(struct repository *repo UNUSED,
+			       const struct conv_attrs *ca,
 			       const char *path, const char *src,
 			       size_t len, struct strbuf *dst,
 			       const struct checkout_metadata *meta)
@@ -1539,6 +1541,32 @@ int convert_to_working_tree_ca(const struct conv_attrs *ca,
 						   meta, NULL);
 }
 
+int convert_to_working_tree(struct index_state *istate,
+			   const char *path, const char *src,
+			   size_t len, struct strbuf *dst,
+			   const struct checkout_metadata *meta)
+{
+	struct repository *repo = istate && istate->repo ?
+				  istate->repo : the_repository;
+	struct conv_attrs ca;
+	convert_attrs(istate, &ca, path);
+	return convert_to_working_tree_ca(repo, &ca, path, src, len, dst, meta);
+}
+
+int async_convert_to_working_tree(struct index_state *istate,
+				  const char *path, const char *src,
+				  size_t len, struct strbuf *dst,
+				  const struct checkout_metadata *meta,
+				  void *dco)
+{
+	struct repository *repo = istate && istate->repo ?
+				  istate->repo : the_repository;
+	struct conv_attrs ca;
+	convert_attrs(istate, &ca, path);
+	return async_convert_to_working_tree_ca(repo, &ca, path, src, len, dst,
+						meta, dco);
+}
+
 int renormalize_buffer(struct index_state *istate, const char *path,
 		       const char *src, size_t len, struct strbuf *dst)
 {
@@ -1981,7 +2009,8 @@ static struct stream_filter *ident_filter(const struct object_id *oid)
  * Note that you would be crazy to set CRLF, smudge/clean or ident to a
  * large binary blob you would want us not to slurp into the memory!
  */
-struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
+struct stream_filter *get_stream_filter_ca(struct repository *repo UNUSED,
+					   const struct conv_attrs *ca,
 					   const struct object_id *oid)
 {
 	struct stream_filter *filter = NULL;
@@ -2006,7 +2035,9 @@ struct stream_filter *get_stream_filter(struct index_state *istate,
 {
 	struct conv_attrs ca;
 	convert_attrs(istate, &ca, path);
-	return get_stream_filter_ca(&ca, oid);
+	return get_stream_filter_ca(istate && istate->repo ?
+				    istate->repo : the_repository,
+				    &ca, oid);
 }
 
 void free_stream_filter(struct stream_filter *filter)
diff --git a/convert.h b/convert.h
index 0a6e4086b8..137fa1593a 100644
--- a/convert.h
+++ b/convert.h
@@ -8,6 +8,7 @@
 #include "string-list.h"
 
 struct index_state;
+struct repository;
 struct strbuf;
 
 #define CONV_EOL_RNDTRP_DIE   (1<<0) /* Die if CRLF to LF to CRLF is different */
@@ -103,34 +104,26 @@ const char *get_convert_attr_ascii(struct index_state *istate,
 int convert_to_git(struct index_state *istate,
 		   const char *path, const char *src, size_t len,
 		   struct strbuf *dst, int conv_flags);
-int convert_to_working_tree_ca(const struct conv_attrs *ca,
+int convert_to_working_tree_ca(struct repository *repo,
+			       const struct conv_attrs *ca,
 			       const char *path, const char *src,
 			       size_t len, struct strbuf *dst,
 			       const struct checkout_metadata *meta);
-int async_convert_to_working_tree_ca(const struct conv_attrs *ca,
+int async_convert_to_working_tree_ca(struct repository *repo,
+				     const struct conv_attrs *ca,
 				     const char *path, const char *src,
 				     size_t len, struct strbuf *dst,
 				     const struct checkout_metadata *meta,
 				     void *dco);
-static inline int convert_to_working_tree(struct index_state *istate,
-					  const char *path, const char *src,
-					  size_t len, struct strbuf *dst,
-					  const struct checkout_metadata *meta)
-{
-	struct conv_attrs ca;
-	convert_attrs(istate, &ca, path);
-	return convert_to_working_tree_ca(&ca, path, src, len, dst, meta);
-}
-static inline int async_convert_to_working_tree(struct index_state *istate,
-						const char *path, const char *src,
-						size_t len, struct strbuf *dst,
-						const struct checkout_metadata *meta,
-						void *dco)
-{
-	struct conv_attrs ca;
-	convert_attrs(istate, &ca, path);
-	return async_convert_to_working_tree_ca(&ca, path, src, len, dst, meta, dco);
-}
+int convert_to_working_tree(struct index_state *istate,
+			   const char *path, const char *src,
+			   size_t len, struct strbuf *dst,
+			   const struct checkout_metadata *meta);
+int async_convert_to_working_tree(struct index_state *istate,
+				  const char *path, const char *src,
+				  size_t len, struct strbuf *dst,
+				  const struct checkout_metadata *meta,
+				  void *dco);
 int async_query_available_blobs(const char *cmd,
 				struct string_list *available_paths);
 int renormalize_buffer(struct index_state *istate,
@@ -183,7 +176,8 @@ struct stream_filter; /* opaque */
 struct stream_filter *get_stream_filter(struct index_state *istate,
 					const char *path,
 					const struct object_id *);
-struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
+struct stream_filter *get_stream_filter_ca(struct repository *repo,
+					   const struct conv_attrs *ca,
 					   const struct object_id *oid);
 void free_stream_filter(struct stream_filter *);
 int is_null_stream_filter(struct stream_filter *);
diff --git a/entry.c b/entry.c
index 1c4f0f4407..7fda86e67f 100644
--- a/entry.c
+++ b/entry.c
@@ -296,11 +296,14 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
 	const struct submodule *sub;
 	struct checkout_metadata meta;
 	static int scratch_nr_checkouts;
+	struct repository *repo = state->istate && state->istate->repo ?
+				  state->istate->repo : the_repository;
 
 	clone_checkout_metadata(&meta, &state->meta, &ce->oid);
 
 	if (ce_mode_s_ifmt == S_IFREG) {
-		struct stream_filter *filter = get_stream_filter_ca(ca, &ce->oid);
+		struct stream_filter *filter =
+			get_stream_filter_ca(repo, ca, &ce->oid);
 		if (filter &&
 		    !streaming_write_entry(ce, path, filter,
 					   state, to_tempfile,
@@ -348,9 +351,11 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
 		 * Convert from git internal format to working tree format
 		 */
 		if (dco && dco->state != CE_NO_DELAY) {
-			ret = async_convert_to_working_tree_ca(ca, ce->name,
+			ret = async_convert_to_working_tree_ca(repo, ca,
+							       ce->name,
 							       new_blob, size,
-							       &buf, &meta, dco);
+							       &buf, &meta,
+							       dco);
 			if (ret) {
 				struct string_list_item *item =
 					string_list_lookup(&dco->paths, ce->name);
@@ -362,8 +367,9 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
 				}
 			}
 		} else {
-			ret = convert_to_working_tree_ca(ca, ce->name, new_blob,
-							 size, &buf, &meta);
+			ret = convert_to_working_tree_ca(repo, ca, ce->name,
+							 new_blob, size, &buf,
+							 &meta);
 		}
 
 		if (ret) {
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 0bf4bd6d4a..51a4db4f67 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -279,7 +279,8 @@ static int write_pc_item_to_fd(struct parallel_checkout_item *pc_item, int fd,
 	/* Sanity check */
 	ASSERT(is_eligible_for_parallel_checkout(pc_item->ce, &pc_item->ca));
 
-	filter = get_stream_filter_ca(&pc_item->ca, &pc_item->ce->oid);
+	filter = get_stream_filter_ca(the_repository, &pc_item->ca,
+					&pc_item->ce->oid);
 	if (filter) {
 		if (odb_stream_blob_to_fd(the_repository->objects, fd,
 					  &pc_item->ce->oid, filter, 1)) {
@@ -302,8 +303,9 @@ static int write_pc_item_to_fd(struct parallel_checkout_item *pc_item, int fd,
 	 * checkout, so pass NULL. Note: if that changes, the metadata must also
 	 * be passed from the main process to the workers.
 	 */
-	ret = convert_to_working_tree_ca(&pc_item->ca, pc_item->ce->name,
-					 blob, size, &buf, NULL);
+	ret = convert_to_working_tree_ca(the_repository, &pc_item->ca,
+					 pc_item->ce->name, blob, size, &buf,
+					 NULL);
 
 	if (ret) {
 		size_t newsize;
-- 
2.43.0
Previous: Aniket GuptaNext: Aniket Gupta
Message 2 of 11 in “environment: move line ending config variables into repo_config_values”
  1. 0/4 environment: move line ending config variables into repo_config_valuesAniket Gupta, Oct 24, 2026
  2. 1/4 convert: pass 'repo' to the working tree conversion functionsAniket Gupta, Oct 24, 2026
  3. 2/4 environment: move auto_crlf into repo_config_valuesAniket Gupta, Oct 24, 2026
  4. 3/4 environment: move core_eol into repo_config_valuesAniket Gupta, Oct 24, 2026
  5. 4/4 environment: move global_conv_flags_eol into repo_config_valuesAniket Gupta, Oct 24, 2026
  6. Patrick SteinhardtOct 26, 2026
  7. Aniket GuptaOct 26, 2026
  8. Patrick SteinhardtOct 26, 2026
  9. Junio C HamanoOct 26, 2026
  10. Patrick SteinhardtNov 3, 2026
  11. Junio C HamanoNov 3, 2026

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.