public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository'
@ 2025-06-10 13:02 Ayush Chandekar
  2025-06-10 13:02 ` [GSOC PATCH 1/2] environment: remove the global variable 'core_preload_index' Ayush Chandekar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ayush Chandekar @ 2025-06-10 13:02 UTC (permalink / raw)
  To: git; +Cc: christian.couder, shyamthakkar001, Ayush Chandekar

The aim of this patch series is to remove the definition '#define USE_THE_REPOSITORY_VARIABLE' 
from "preload-index.c" by removing global variables and the global 'the_repository'.

This patch series contains two patches:

1 - Remove the global variable 'core_preload_index' and localize it in the function which calls it.

2 - Remove the dependency of 'the_repository' in "preload-index.c", allowing the removal of 
the definition.

Removing these global variables is part of my GSoC project.

Ayush Chandekar (2):
  environment: remove the global variable 'core_preload_index'
  preload-index: stop depending on 'the_repository'

 config.c        | 5 -----
 environment.c   | 3 ---
 environment.h   | 1 -
 preload-index.c | 7 +++++--
 4 files changed, 5 insertions(+), 11 deletions(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [GSOC PATCH 1/2] environment: remove the global variable 'core_preload_index'
  2025-06-10 13:02 [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Ayush Chandekar
@ 2025-06-10 13:02 ` Ayush Chandekar
  2025-06-10 13:02 ` [GSOC PATCH 2/2] preload-index: stop depending on 'the_repository' Ayush Chandekar
  2025-06-10 17:11 ` [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Junio C Hamano
  2 siblings, 0 replies; 4+ messages in thread
From: Ayush Chandekar @ 2025-06-10 13:02 UTC (permalink / raw)
  To: git; +Cc: christian.couder, shyamthakkar001, Ayush Chandekar

The global variable 'core_preload_index' is used in a single function
named 'preload_index()' in "preload-index.c". Move its declaration inside
that function, removing unnecessary global state.

This change is part of an ongoing effort to eliminate global variables,
improve modularity and help libify the codebase.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com>
---
 config.c        | 5 -----
 environment.c   | 3 ---
 environment.h   | 1 -
 preload-index.c | 4 ++++
 4 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/config.c b/config.c
index b18b5617fc..eb60c293ab 100644
--- a/config.c
+++ b/config.c
@@ -1595,11 +1595,6 @@ static int git_default_core_config(const char *var, const char *value,
 		return 0;
 	}
 
-	if (!strcmp(var, "core.preloadindex")) {
-		core_preload_index = git_config_bool(var, value);
-		return 0;
-	}
-
 	if (!strcmp(var, "core.createobject")) {
 		if (!value)
 			return config_error_nonbool(var);
diff --git a/environment.c b/environment.c
index c61d773e7e..7bf0390a33 100644
--- a/environment.c
+++ b/environment.c
@@ -113,9 +113,6 @@ const char *comment_line_str = "#";
 char *comment_line_str_to_free;
 int auto_comment_line_char;
 
-/* Parallel index stat data preload? */
-int core_preload_index = 1;
-
 /* This is set by setup_git_directory_gently() and/or git_default_config() */
 char *git_work_tree_cfg;
 
diff --git a/environment.h b/environment.h
index 3d98461a06..9a3d05d414 100644
--- a/environment.h
+++ b/environment.h
@@ -155,7 +155,6 @@ extern int pack_compression_level;
 extern unsigned long pack_size_limit_cfg;
 extern int max_allowed_tree_depth;
 
-extern int core_preload_index;
 extern int precomposed_unicode;
 extern int protect_hfs;
 extern int protect_ntfs;
diff --git a/preload-index.c b/preload-index.c
index 40ab2abafb..9fee4cc3aa 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -19,6 +19,7 @@
 #include "repository.h"
 #include "symlinks.h"
 #include "trace2.h"
+#include "config.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
@@ -111,6 +112,9 @@ void preload_index(struct index_state *index,
 	struct thread_data data[MAX_PARALLEL];
 	struct progress_data pd;
 	int t2_sum_lstat = 0;
+	int core_preload_index = 1;
+
+	repo_config_get_bool(the_repository, "core.preloadindex", &core_preload_index);
 
 	if (!HAVE_THREADS || !core_preload_index)
 		return;
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [GSOC PATCH 2/2] preload-index: stop depending on 'the_repository'
  2025-06-10 13:02 [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Ayush Chandekar
  2025-06-10 13:02 ` [GSOC PATCH 1/2] environment: remove the global variable 'core_preload_index' Ayush Chandekar
@ 2025-06-10 13:02 ` Ayush Chandekar
  2025-06-10 17:11 ` [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Junio C Hamano
  2 siblings, 0 replies; 4+ messages in thread
From: Ayush Chandekar @ 2025-06-10 13:02 UTC (permalink / raw)
  To: git; +Cc: christian.couder, shyamthakkar001, Ayush Chandekar

Refactor "preload-index.c" to remove the dependency on the global
'the_repository'. Replace the occurrences of 'the_repository' with
'index->repo' and thus remove the definition '#define
USE_THE_REPOSITORY_VARIABLE'.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com>
---
 preload-index.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/preload-index.c b/preload-index.c
index 9fee4cc3aa..b222821b44 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -2,7 +2,6 @@
  * Copyright (C) 2008 Linus Torvalds
  */
 
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -114,7 +113,7 @@ void preload_index(struct index_state *index,
 	int t2_sum_lstat = 0;
 	int core_preload_index = 1;
 
-	repo_config_get_bool(the_repository, "core.preloadindex", &core_preload_index);
+	repo_config_get_bool(index->repo, "core.preloadindex", &core_preload_index);
 
 	if (!HAVE_THREADS || !core_preload_index)
 		return;
@@ -136,7 +135,7 @@ void preload_index(struct index_state *index,
 
 	memset(&pd, 0, sizeof(pd));
 	if (refresh_flags & REFRESH_PROGRESS && isatty(2)) {
-		pd.progress = start_delayed_progress(the_repository,
+		pd.progress = start_delayed_progress(index->repo,
 						     _("Refreshing index"),
 						     index->cache_nr);
 		pthread_mutex_init(&pd.mutex, NULL);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository'
  2025-06-10 13:02 [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Ayush Chandekar
  2025-06-10 13:02 ` [GSOC PATCH 1/2] environment: remove the global variable 'core_preload_index' Ayush Chandekar
  2025-06-10 13:02 ` [GSOC PATCH 2/2] preload-index: stop depending on 'the_repository' Ayush Chandekar
@ 2025-06-10 17:11 ` Junio C Hamano
  2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2025-06-10 17:11 UTC (permalink / raw)
  To: Ayush Chandekar; +Cc: git, christian.couder, shyamthakkar001

Ayush Chandekar <ayu.chandekar@gmail.com> writes:

> The aim of this patch series is to remove the definition '#define
> USE_THE_REPOSITORY_VARIABLE' from "preload-index.c" by removing
> global variables and the global 'the_repository'.
>
> This patch series contains two patches:
>
> 1 - Remove the global variable 'core_preload_index' and localize
> it in the function which calls it.
>
> 2 - Remove the dependency of 'the_repository' in
> "preload-index.c", allowing the removal of the definition.
>
> Removing these global variables is part of my GSoC project.

Both patches are pretty straight-forward and readable.  Will queue.  Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-10 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 13:02 [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-06-10 13:02 ` [GSOC PATCH 1/2] environment: remove the global variable 'core_preload_index' Ayush Chandekar
2025-06-10 13:02 ` [GSOC PATCH 2/2] preload-index: stop depending on 'the_repository' Ayush Chandekar
2025-06-10 17:11 ` [GSOC PATCH 0/2] preload-index: remove dependency on global variables and 'the_repository' Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox