Skip to content

Commit 8e2e8a3

Browse files
pks-tgitster
authored andcommitted
environment: stop storing "core.preferSymlinkRefs" globally
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eafb126 commit 8e2e8a3

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

config.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,11 +1447,6 @@ static int git_default_core_config(const char *var, const char *value,
14471447
return 0;
14481448
}
14491449

1450-
if (!strcmp(var, "core.prefersymlinkrefs")) {
1451-
prefer_symlink_refs = git_config_bool(var, value);
1452-
return 0;
1453-
}
1454-
14551450
if (!strcmp(var, "core.warnambiguousrefs")) {
14561451
warn_ambiguous_refs = git_config_bool(var, value);
14571452
return 0;

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ int has_symlinks = 1;
3434
int minimum_abbrev = 4, default_abbrev = -1;
3535
int ignore_case;
3636
int assume_unchanged;
37-
int prefer_symlink_refs;
3837
int is_bare_repository_cfg = -1; /* unspecified */
3938
int warn_ambiguous_refs = 1;
4039
int warn_on_object_refname_ambiguity = 1;

environment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ extern int has_symlinks;
156156
extern int minimum_abbrev, default_abbrev;
157157
extern int ignore_case;
158158
extern int assume_unchanged;
159-
extern int prefer_symlink_refs;
160159
extern int warn_ambiguous_refs;
161160
extern int warn_on_object_refname_ambiguity;
162161
extern char *apply_default_whitespace;

refs/files-backend.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22

33
#include "../git-compat-util.h"
4+
#include "../config.h"
45
#include "../copy.h"
56
#include "../environment.h"
67
#include "../gettext.h"
@@ -76,6 +77,7 @@ struct files_ref_store {
7677

7778
char *gitcommondir;
7879
enum log_refs_config log_all_ref_updates;
80+
int prefer_symlink_refs;
7981

8082
struct ref_cache *loose;
8183

@@ -109,6 +111,7 @@ static struct ref_store *files_ref_store_init(struct repository *repo,
109111
refs->packed_ref_store =
110112
packed_ref_store_init(repo, refs->gitcommondir, flags);
111113
refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
114+
repo_config_get_bool(repo, "core.prefersymlinkrefs", &refs->prefer_symlink_refs);
112115

113116
chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
114117
chdir_notify_reparent("files-backend $GIT_COMMONDIR",
@@ -2942,7 +2945,7 @@ static int files_transaction_finish(struct ref_store *ref_store,
29422945
* We try creating a symlink, if that succeeds we continue to the
29432946
* next update. If not, we try and create a regular symref.
29442947
*/
2945-
if (update->new_target && prefer_symlink_refs)
2948+
if (update->new_target && refs->prefer_symlink_refs)
29462949
if (!create_ref_symlink(lock, update->new_target))
29472950
continue;
29482951

0 commit comments

Comments
 (0)