From: Aniket Gupta <aniketgupta3001@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, christian.couder@gmail.com, cat@malon.dev,
belkid98@gmail.com, ps@pks.im, phillip.wood123@gmail.com
Subject: [PATCH 1/4] convert: pass 'repo' to the working tree conversion functions
Date: Sat, 24 Oct 2026 22:00:09 +0000 [thread overview]
Message-ID: <20261024220012.486-2-aniketgupta3001@gmail.com> (raw)
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
next prev parent reply other threads:[~2026-10-24 22:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 22:00 [PATCH 0/4] environment: move line ending config variables into repo_config_values Aniket Gupta
2026-10-24 22:00 ` Aniket Gupta [this message]
2026-10-24 22:00 ` [PATCH 2/4] environment: move auto_crlf " Aniket Gupta
2026-10-24 22:00 ` [PATCH 3/4] environment: move core_eol " Aniket Gupta
2026-10-24 22:00 ` [PATCH 4/4] environment: move global_conv_flags_eol " Aniket Gupta
2026-10-26 12:27 ` [PATCH 0/4] environment: move line ending config variables " Patrick Steinhardt
2026-10-26 13:10 ` Aniket Gupta
2026-10-26 13:25 ` Patrick Steinhardt
2026-10-26 15:53 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261024220012.486-2-aniketgupta3001@gmail.com \
--to=aniketgupta3001@gmail.com \
--cc=belkid98@gmail.com \
--cc=cat@malon.dev \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox