@@ -9,6 +9,7 @@
#include "pathspec.h"
#include "object.h"
#include "statinfo.h"
+#include "global-config.h"
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
@@ -160,10 +161,14 @@ 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 trust_executable_bit, has_symlinks;
+ extern int has_symlinks;
+ int trust_executable_bit;
+
if (!has_symlinks && S_ISREG(mode) &&
ce && S_ISLNK(ce->ce_mode))
return ce->ce_mode;
+
+ trust_executable_bit = get_int_config_global(INT_CONFIG_TRUST_EXECUTABLE_BIT);
if (!trust_executable_bit && S_ISREG(mode)) {
if (ce && S_ISREG(ce->ce_mode))
return ce->ce_mode;
@@ -1561,11 +1561,6 @@ int git_config_color(char *dest, const char *var, const char *value)
static int git_default_core_config(const char *var, const char *value, void *cb)
{
- /* This needs a better name */
- if (!strcmp(var, "core.filemode")) {
- trust_executable_bit = git_config_bool(var, value);
- return 0;
- }
if (!strcmp(var, "core.trustctime")) {
trust_ctime = git_config_bool(var, value);
return 0;
@@ -30,7 +30,6 @@
#include "wrapper.h"
#include "write-or-die.h"
-int trust_executable_bit = 1;
int trust_ctime = 1;
int check_stat = 1;
int has_symlinks = 1;
@@ -111,7 +111,6 @@ void set_git_work_tree(const char *tree);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
/* Environment bits from configuration mechanism */
-extern int trust_executable_bit;
extern int trust_ctime;
extern int check_stat;
extern int has_symlinks;
@@ -4,6 +4,7 @@
static int global_ints[] = {
[INT_CONFIG_NONE] = 0, /* unused*/
+ [INT_CONFIG_TRUST_EXECUTABLE_BIT] = 1,
};
/* Bitmask for the enum. */
@@ -11,6 +12,7 @@ static uint64_t global_ints_initialized;
static const char *global_int_names[] = {
[INT_CONFIG_NONE] = NULL, /* unused*/
+ [INT_CONFIG_TRUST_EXECUTABLE_BIT] = "core.filemode",
};
static int config_available;
@@ -3,6 +3,7 @@
enum int_config_key {
INT_CONFIG_NONE = 0,
+ INT_CONFIG_TRUST_EXECUTABLE_BIT,
};
/**
@@ -336,7 +336,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
/* We consider only the owner x bit to be relevant for
* "mode changes"
*/
- if (trust_executable_bit &&
+ if (get_int_config_global(INT_CONFIG_TRUST_EXECUTABLE_BIT) &&
(0100 & (ce->ce_mode ^ st->st_mode)))
changed |= MODE_CHANGED;
break;
@@ -806,7 +806,8 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
ce->ce_flags |= CE_INTENT_TO_ADD;
- if (trust_executable_bit && has_symlinks) {
+ if (get_int_config_global(INT_CONFIG_TRUST_EXECUTABLE_BIT) &&
+ has_symlinks) {
ce->ce_mode = create_ce_mode(st_mode);
} else {
/* If there is an existing entry, pick the mode bits and type