@@ -4384,7 +4384,8 @@ static int try_create_file(struct apply_state *state, const char *path,
return !!mkdir(path, 0777);
}
- if (has_symlinks && S_ISLNK(mode))
+ if (get_int_config_global(INT_CONFIG_HAS_SYMLINKS) &&
+ S_ISLNK(mode))
/* Although buf:size is counted string, it also is NUL
* terminated.
*/
@@ -292,7 +292,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)
if (is_null_oid(oid)) {
/* The symlink is unknown to Git so read from the filesystem */
struct strbuf link = STRBUF_INIT;
- if (has_symlinks) {
+ if (get_int_config_global(INT_CONFIG_HAS_SYMLINKS)) {
if (strbuf_readlink(&link, path, strlen(path)))
die(_("could not read symlink %s"), path);
} else if (strbuf_read_file(&link, path, 128))
@@ -723,7 +723,7 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
struct child_process child = CHILD_PROCESS_INIT;
git_config(difftool_config, NULL);
- symlinks = has_symlinks;
+ symlinks = get_int_config_global(INT_CONFIG_HAS_SYMLINKS);
argc = parse_options(argc, argv, prefix, builtin_difftool_options,
builtin_difftool_usage, PARSE_OPT_KEEP_UNKNOWN_OPT |
@@ -161,10 +161,10 @@ static inline unsigned create_ce_flags(unsigned stage)
static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
unsigned int mode)
{
- extern int has_symlinks;
int trust_executable_bit;
- if (!has_symlinks && S_ISREG(mode) &&
+ if (!get_int_config_global(INT_CONFIG_HAS_SYMLINKS) &&
+ S_ISREG(mode) &&
ce && S_ISLNK(ce->ce_mode))
return ce->ce_mode;
@@ -1086,7 +1086,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
/* if symlinks don't work, assume symlink if all parents
* are symlinks
*/
- is_file = has_symlinks;
+ is_file = get_int_config_global(INT_CONFIG_HAS_SYMLINKS);
for (i = 0; !is_file && i < num_parent; i++)
is_file = !S_ISLNK(elem->parent[i].mode);
if (!is_file)
@@ -1568,11 +1568,6 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
check_stat = 0;
}
- if (!strcmp(var, "core.symlinks")) {
- has_symlinks = git_config_bool(var, value);
- return 0;
- }
-
if (!strcmp(var, "core.ignorecase")) {
ignore_case = git_config_bool(var, value);
return 0;
@@ -308,7 +308,8 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
* We can't make a real symlink; write out a regular file entry
* with the symlink destination as its contents.
*/
- if (!has_symlinks || to_tempfile)
+ if (!get_int_config_global(INT_CONFIG_HAS_SYMLINKS) ||
+ to_tempfile)
goto write_file_entry;
ret = symlink(new_blob, path);
@@ -31,7 +31,6 @@
#include "write-or-die.h"
int check_stat = 1;
-int has_symlinks = 1;
int minimum_abbrev = 4, default_abbrev = -1;
int ignore_case;
int assume_unchanged;
@@ -112,7 +112,6 @@ void set_git_work_tree(const char *tree);
/* Environment bits from configuration mechanism */
extern int check_stat;
-extern int has_symlinks;
extern int minimum_abbrev, default_abbrev;
extern int ignore_case;
extern int assume_unchanged;
@@ -7,6 +7,7 @@ static int global_ints[] = {
[INT_CONFIG_TRUST_EXECUTABLE_BIT] = 1,
[INT_CONFIG_TRUST_CTIME] = 1,
[INT_CONFIG_QUOTE_PATH_FULLY] = 1,
+ [INT_CONFIG_HAS_SYMLINKS] = 1,
};
/* Bitmask for the enum. */
@@ -17,6 +18,7 @@ static const char *global_int_names[] = {
[INT_CONFIG_TRUST_EXECUTABLE_BIT] = "core.filemode",
[INT_CONFIG_TRUST_CTIME] = "core.trustctime",
[INT_CONFIG_QUOTE_PATH_FULLY] = "core.quotepath",
+ [INT_CONFIG_HAS_SYMLINKS] = "core.symlinks",
};
static int config_available;
@@ -6,6 +6,7 @@ enum int_config_key {
INT_CONFIG_TRUST_EXECUTABLE_BIT,
INT_CONFIG_TRUST_CTIME,
INT_CONFIG_QUOTE_PATH_FULLY,
+ INT_CONFIG_HAS_SYMLINKS,
};
/**
@@ -983,7 +983,8 @@ static int update_file_flags(struct merge_options *opt,
goto free_buf;
}
if (S_ISREG(contents->mode) ||
- (!has_symlinks && S_ISLNK(contents->mode))) {
+ (!get_int_config_global(INT_CONFIG_HAS_SYMLINKS) &&
+ S_ISLNK(contents->mode))) {
int fd;
int mode = (contents->mode & 0100 ? 0777 : 0666);
@@ -344,7 +344,8 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
break;
case S_IFLNK:
if (!S_ISLNK(st->st_mode) &&
- (has_symlinks || !S_ISREG(st->st_mode)))
+ (get_int_config_global(INT_CONFIG_HAS_SYMLINKS) ||
+ !S_ISREG(st->st_mode)))
changed |= TYPE_CHANGED;
break;
case S_IFGITLINK:
@@ -809,7 +810,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
if (get_int_config_global(INT_CONFIG_TRUST_EXECUTABLE_BIT) &&
- has_symlinks) {
+ get_int_config_global(INT_CONFIG_HAS_SYMLINKS)) {
ce->ce_mode = create_ce_mode(st_mode);
} else {
/* If there is an existing entry, pick the mode bits and type