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 3/4] environment: move core_eol into repo_config_values
Date: Sat, 24 Oct 2026 22:00:11 +0000 [thread overview]
Message-ID: <20261024220012.486-4-aniketgupta3001@gmail.com> (raw)
In-Reply-To: <20261024220012.486-1-aniketgupta3001@gmail.com>
The global variable 'core_eol' holds the value of the 'core.eol'
configuration, which sets the line ending used for files that are
converted to the working tree format. Move it into 'struct
repo_config_values' to continue the libification effort.
As with 'enum auto_crlf', moving 'enum eol' to 'convert.h' would
introduce a circular dependency chain:
convert.h -> hash.h -> repository.h -> environment.h.
Therefore, keep the enum definition in 'environment.h' next to the
other ones, under the existing NEEDSWORK comment. Initialize the
per-repository value to its default in 'repo_config_values_init()'.
Modify the configuration parsing in environment.c to update the
per-repository structure directly, and introduce the getter
'repo_core_eol()' to read the value in 'convert.c'.
Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
convert.c | 6 +++---
convert.h | 12 ------------
environment.c | 17 ++++++++++++-----
environment.h | 14 ++++++++++++++
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/convert.c b/convert.c
index 7c7fdd4b2d..1d4e8a246b 100644
--- a/convert.c
+++ b/convert.c
@@ -164,9 +164,9 @@ static int text_eol_is_crlf(struct repository *repo)
return 1;
else if (repo_auto_crlf(repo) == AUTO_CRLF_INPUT)
return 0;
- if (core_eol == EOL_CRLF)
+ if (repo_core_eol(repo) == EOL_CRLF)
return 1;
- if (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)
+ if (repo_core_eol(repo) == EOL_UNSET && EOL_NATIVE == EOL_CRLF)
return 1;
return 0;
}
@@ -192,7 +192,7 @@ static enum eol output_eol(struct repository *repo,
return text_eol_is_crlf(repo) ? EOL_CRLF : EOL_LF;
}
warning(_("illegal crlf_action %d"), (int)crlf_action);
- return core_eol;
+ return repo_core_eol(repo);
}
static void check_global_conv_flags_eol(const char *path,
diff --git a/convert.h b/convert.h
index dae11d372d..3c51130177 100644
--- a/convert.h
+++ b/convert.h
@@ -19,17 +19,6 @@ struct strbuf;
extern int global_conv_flags_eol;
-enum eol {
- EOL_UNSET,
- EOL_CRLF,
- EOL_LF,
-#ifdef NATIVE_CRLF
- EOL_NATIVE = EOL_CRLF
-#else
- EOL_NATIVE = EOL_LF
-#endif
-};
-
enum ce_delay_state {
CE_NO_DELAY = 0,
CE_CAN_DELAY = 1,
@@ -84,7 +73,6 @@ struct conv_attrs {
void convert_attrs(struct index_state *istate,
struct conv_attrs *ca, const char *path);
-extern enum eol core_eol;
extern char *check_roundtrip_encoding;
const char *get_cached_convert_stats_ascii(struct index_state *istate,
const char *path);
diff --git a/environment.c b/environment.c
index bbac8ed8c9..6445994986 100644
--- a/environment.c
+++ b/environment.c
@@ -49,7 +49,6 @@ int fsync_object_files = -1;
int use_fsync = -1;
enum fsync_method fsync_method = FSYNC_METHOD_DEFAULT;
enum fsync_component fsync_components = FSYNC_COMPONENTS_DEFAULT;
-enum eol core_eol = EOL_UNSET;
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
char *check_roundtrip_encoding;
#ifndef OBJECT_CREATION_MODE
@@ -158,6 +157,13 @@ enum auto_crlf repo_auto_crlf(struct repository *repo)
: AUTO_CRLF_FALSE;
}
+enum eol repo_core_eol(struct repository *repo)
+{
+ return repo->initialized
+ ? repo_config_values(repo)->core_eol
+ : EOL_UNSET;
+}
+
const char *repo_excludes_file(struct repository *repo)
{
struct repo_config_values *cfg = repo_config_values(repo);
@@ -447,13 +453,13 @@ int git_default_core_config(const char *var, const char *value,
if (!strcmp(var, "core.eol")) {
if (value && !strcasecmp(value, "lf"))
- core_eol = EOL_LF;
+ cfg->core_eol = EOL_LF;
else if (value && !strcasecmp(value, "crlf"))
- core_eol = EOL_CRLF;
+ cfg->core_eol = EOL_CRLF;
else if (value && !strcasecmp(value, "native"))
- core_eol = EOL_NATIVE;
+ cfg->core_eol = EOL_NATIVE;
else
- core_eol = EOL_UNSET;
+ cfg->core_eol = EOL_UNSET;
return 0;
}
@@ -784,6 +790,7 @@ void repo_config_values_init(struct repo_config_values *cfg)
cfg->has_symlinks = platform_has_symlinks();
cfg->use_nanosec = 0;
cfg->auto_crlf = AUTO_CRLF_FALSE;
+ cfg->core_eol = EOL_UNSET;
/* section "sparse" config values */
cfg->sparse_expect_files_outside_of_patterns = 0;
diff --git a/environment.h b/environment.h
index 872da3576b..bf6701560d 100644
--- a/environment.h
+++ b/environment.h
@@ -129,6 +129,17 @@ enum auto_crlf {
AUTO_CRLF_INPUT = -1
};
+enum eol {
+ EOL_UNSET,
+ EOL_CRLF,
+ EOL_LF,
+#ifdef NATIVE_CRLF
+ EOL_NATIVE = EOL_CRLF
+#else
+ EOL_NATIVE = EOL_LF
+#endif
+};
+
struct repo_config_values {
/* section "core" config values */
char *attributes_file;
@@ -156,6 +167,7 @@ struct repo_config_values {
int has_symlinks;
int use_nanosec;
enum auto_crlf auto_crlf;
+ enum eol core_eol;
/* section "sparse" config values */
int sparse_expect_files_outside_of_patterns;
@@ -212,6 +224,8 @@ int repo_has_symlinks(struct repository *repo);
enum auto_crlf repo_auto_crlf(struct repository *repo);
+enum eol repo_core_eol(struct repository *repo);
+
const char *repo_excludes_file(struct repository *repo);
void repo_config_values_init(struct repo_config_values *cfg);
--
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 ` [PATCH 1/4] convert: pass 'repo' to the working tree conversion functions Aniket Gupta
2026-10-24 22:00 ` [PATCH 2/4] environment: move auto_crlf into repo_config_values Aniket Gupta
2026-10-24 22:00 ` Aniket Gupta [this message]
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-4-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