]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: stop storing "core.preferSymlinkRefs" globally
authorPatrick Steinhardt <ps@pks.im>
Thu, 12 Sep 2024 11:30:21 +0000 (13:30 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2024 17:15:43 +0000 (10:15 -0700)
Same as the preceding commit, storing the "core.preferSymlinkRefs" value
globally is misdesigned as this setting may be set per repository.

There is only a single user of this value anyway, namely the "files"
backend. So let's just remove the global variable and read the value of
this setting when initializing the backend.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
environment.c
environment.h
refs/files-backend.c

index 47101c3e9775ef01632abb1061c77995c7cc9e97..a59890180a373ee3b309ec1d8e31e2021a958e62 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1447,11 +1447,6 @@ static int git_default_core_config(const char *var, const char *value,
                return 0;
        }
 
-       if (!strcmp(var, "core.prefersymlinkrefs")) {
-               prefer_symlink_refs = git_config_bool(var, value);
-               return 0;
-       }
-
        if (!strcmp(var, "core.warnambiguousrefs")) {
                warn_ambiguous_refs = git_config_bool(var, value);
                return 0;
index 992d87e0d60e4b7a6d40738508779561377b9e80..6805c7b01dfe51aacf092a255fbe9b9c556b64b1 100644 (file)
@@ -34,7 +34,6 @@ int has_symlinks = 1;
 int minimum_abbrev = 4, default_abbrev = -1;
 int ignore_case;
 int assume_unchanged;
-int prefer_symlink_refs;
 int is_bare_repository_cfg = -1; /* unspecified */
 int warn_ambiguous_refs = 1;
 int warn_on_object_refname_ambiguity = 1;
index 315fd31995163905c854b8c37fccf24828379420..0cab644e2d35801b5b2f0c33a1c95484da070305 100644 (file)
@@ -156,7 +156,6 @@ extern int has_symlinks;
 extern int minimum_abbrev, default_abbrev;
 extern int ignore_case;
 extern int assume_unchanged;
-extern int prefer_symlink_refs;
 extern int warn_ambiguous_refs;
 extern int warn_on_object_refname_ambiguity;
 extern char *apply_default_whitespace;
index a536d7d1b57e9a50df01d409e19319efe4051485..e5b0aff00dcfad07c892c691af789e985313d3ac 100644 (file)
@@ -1,6 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "../git-compat-util.h"
+#include "../config.h"
 #include "../copy.h"
 #include "../environment.h"
 #include "../gettext.h"
@@ -76,6 +77,7 @@ struct files_ref_store {
 
        char *gitcommondir;
        enum log_refs_config log_all_ref_updates;
+       int prefer_symlink_refs;
 
        struct ref_cache *loose;
 
@@ -109,6 +111,7 @@ static struct ref_store *files_ref_store_init(struct repository *repo,
        refs->packed_ref_store =
                packed_ref_store_init(repo, refs->gitcommondir, flags);
        refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
+       repo_config_get_bool(repo, "core.prefersymlinkrefs", &refs->prefer_symlink_refs);
 
        chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
        chdir_notify_reparent("files-backend $GIT_COMMONDIR",
@@ -2942,7 +2945,7 @@ static int files_transaction_finish(struct ref_store *ref_store,
                 * We try creating a symlink, if that succeeds we continue to the
                 * next update. If not, we try and create a regular symref.
                 */
-               if (update->new_target && prefer_symlink_refs)
+               if (update->new_target && refs->prefer_symlink_refs)
                        if (!create_ref_symlink(lock, update->new_target))
                                continue;