All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tian Yuchen <cat@malon.dev>
To: git@vger.kernel.org
Cc: ps@pks.im, Tian Yuchen <cat@malon.dev>,
	Christian Couder <christian.couder@gmail.com>,
	Ayush Chandekar <ayu.chandekar@gmail.com>,
	Olamide Caleb Bello <belkid98@gmail.com>
Subject: [PATCH v2 2/2] environment: migrate assume_unchanged into repo_config_values
Date: Tue, 28 Jul 2026 09:46:30 +0800	[thread overview]
Message-ID: <20260728014630.3284974-3-cat@malon.dev> (raw)
In-Reply-To: <20260728014630.3284974-1-cat@malon.dev>

Move the global 'assume_unchanged' configuration into the
repository-specific 'repo_config_values' struct.

We do not introduce a getter for it because the readers are
limited and no hardcoded fallback values are needed.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
---
 builtin/update-index.c | 3 ++-
 environment.c          | 4 ++--
 environment.h          | 2 +-
 read-cache.c           | 9 ++++++---
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 4c4b39a157..3ef7e9bb90 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -419,6 +419,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid,
 {
 	int len, option;
 	struct cache_entry *ce;
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 
 	if (!verify_path(path, mode))
 		return error("Invalid path '%s'", path);
@@ -431,7 +432,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid,
 	ce->ce_flags = create_ce_flags(stage);
 	ce->ce_namelen = len;
 	ce->ce_mode = create_ce_mode(mode);
-	if (assume_unchanged)
+	if (cfg->assume_unchanged)
 		ce->ce_flags |= CE_VALID;
 	option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
 	option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
diff --git a/environment.c b/environment.c
index 53623518c7..12659c1d9c 100644
--- a/environment.c
+++ b/environment.c
@@ -44,7 +44,6 @@ static int zlib_compression_seen;
 int trust_executable_bit = 1;
 int has_symlinks = 1;
 int minimum_abbrev = 4, default_abbrev = -1;
-int assume_unchanged;
 char *git_commit_encoding;
 char *git_log_output_encoding;
 char *apply_default_whitespace;
@@ -355,7 +354,7 @@ int git_default_core_config(const char *var, const char *value,
 	}
 
 	if (!strcmp(var, "core.ignorestat")) {
-		assume_unchanged = git_config_bool(var, value);
+		cfg->assume_unchanged = git_config_bool(var, value);
 		return 0;
 	}
 
@@ -737,6 +736,7 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->check_stat = 1;
 	cfg->zlib_compression_level = Z_BEST_SPEED;
 	cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
+	cfg->assume_unchanged = 0;
 	cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 	cfg->core_sparse_checkout_cone = 0;
 	cfg->sparse_expect_files_outside_of_patterns = 0;
diff --git a/environment.h b/environment.h
index 2e0f8beac0..3a391338e3 100644
--- a/environment.h
+++ b/environment.h
@@ -95,6 +95,7 @@ struct repo_config_values {
 	int check_stat;
 	int zlib_compression_level;
 	int pack_compression_level;
+	int assume_unchanged;
 	int precomposed_unicode;
 	int core_sparse_checkout_cone;
 	int warn_on_object_refname_ambiguity;
@@ -183,7 +184,6 @@ int have_git_dir(void);
 extern int trust_executable_bit;
 extern int has_symlinks;
 extern int minimum_abbrev, default_abbrev;
-extern int assume_unchanged;
 extern char *apply_default_whitespace;
 extern char *apply_default_ignorewhitespace;
 
diff --git a/read-cache.c b/read-cache.c
index 38b55323dd..643b13f1fb 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -192,9 +192,11 @@ void rename_index_entry_at(struct index_state *istate, int nr, const char *new_n
  */
 void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st)
 {
+	struct repo_config_values *cfg = repo_config_values(the_repository);
+
 	fill_stat_data(&ce->ce_stat_data, st);
 
-	if (assume_unchanged)
+	if (cfg->assume_unchanged)
 		ce->ce_flags |= CE_VALID;
 
 	if (S_ISREG(st->st_mode)) {
@@ -1346,6 +1348,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
 {
 	struct stat st;
 	struct cache_entry *updated;
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 	int changed;
 	int refresh = options & CE_MATCH_REFRESH;
 	int ignore_valid = options & CE_MATCH_IGNORE_VALID;
@@ -1405,7 +1408,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
 		 * is not marked VALID, this is the place to mark it
 		 * valid again, under "assume unchanged" mode.
 		 */
-		if (ignore_valid && assume_unchanged &&
+		if (ignore_valid && cfg->assume_unchanged &&
 		    !(ce->ce_flags & CE_VALID))
 			; /* mark this one VALID again */
 		else {
@@ -1440,7 +1443,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
 	 * (i.e. things to be edited) will reacquire CE_VALID bit
 	 * automatically, which is not really what we want.
 	 */
-	if (!ignore_valid && assume_unchanged &&
+	if (!ignore_valid && cfg->assume_unchanged &&
 	    !(ce->ce_flags & CE_VALID))
 		updated->ce_flags &= ~CE_VALID;
 
-- 
2.43.0


      parent reply	other threads:[~2026-07-28  1:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 11:54 [PATCH v1 0/3] environment: migrate more global variables, pt.2 Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 1/3] environment: migrate minimum_abbrev and default_abbrev Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 2/3] environment: migrate pack_size_limit_cfg into repo_config_values Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 3/3] environment: migrate assume_unchanged " Tian Yuchen
2026-07-25 17:02 ` [PATCH v1 0/3] environment: migrate more global variables, pt.2 Junio C Hamano
2026-07-26  6:29   ` Tian Yuchen
2026-07-28  1:46 ` [PATCH v2 0/2] environment: migrate more global variables into Tian Yuchen
2026-07-28  1:46   ` [PATCH v2 1/2] environment: migrate pack_size_limit_cfg into repo_config_values Tian Yuchen
2026-07-28  1:46   ` Tian Yuchen [this message]

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=20260728014630.3284974-3-cat@malon.dev \
    --to=cat@malon.dev \
    --cc=ayu.chandekar@gmail.com \
    --cc=belkid98@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.