From: Shreyansh Paliwal Date: Tue, 10 Mar 2026 17:40:47 GMT Subject: [GSOC][PATCH v2 0/2] Remove global state from editor.c Message-ID: <20260310174519.676851-1-shreyanshpaliwalcmsmn@gmail.com> In-Reply-To: <20260301105228.1738388-1-shreyanshpaliwalcmsmn@gmail.com> This series reduces reliance on global states. Mainly there are two such global states in editor.c, * editor_program: defined in environment.c and populated during config parsing, but only used by editor.c via git_editor(). * the_repository: used in git_sequence_editor() to read the sequence.editor configuration. In patch 1/2, localize editor_program to editor.c by introducing a helper that allows git_default_core_config() to continue initializing the value during initial config parsing. In patch 2/2, remove the remaining use of the_repository in editor.c by passing struct repository through git_sequence_editor() and its callers. With this change, editor.c no longer requires 'USE_THE_REPOSITORY_VARIABLE' and 'environment.h' include. Shreyansh Paliwal (2): editor: make editor_program local to editor.c editor: remove the_repository usage builtin/var.c | 2 +- editor.c | 19 ++++++++++++------- editor.h | 6 ++++-- environment.c | 5 ++--- environment.h | 1 - rebase-interactive.c | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) --- Changes in v2: - removed 'environment.h' dependency from editor.c as well. Range-diff against v1: -: ---------- > 1: 6f8b82fed5 editor: make editor_program local to editor.c 1: f9ef18b77a ! 2: 5b858c7e98 editor: remove the_repository usage @@ Commit message local repository instance, so pass it down the caller. With no remaining global states in editor.c remove '#define - USE_THE_REPOSITORY_VARIABLE'. This removes another dependency on - the_repository and keeps editor code consistent with the ongoing effort to - reduce global state. + USE_THE_REPOSITORY_VARIABLE' and drop the dependency on 'environment.h'. + This removes another dependency on the_repository and keeps editor code + consistent with the ongoing effort to reduce global state. Signed-off-by: Shreyansh Paliwal @@ editor.c #include "git-compat-util.h" #include "abspath.h" #include "advice.h" + #include "config.h" + #include "editor.h" +-#include "environment.h" + #include "gettext.h" + #include "pager.h" + #include "path.h" @@ editor.c: const char *git_editor(void) return editor; } -- 2.53.0