mirror of
https://github.com/git/git.git
synced 2026-01-18 14:44:28 +00:00
Merge branch 'perl5lib'
With this topic branch, the PERL5LIB variable is unset to avoid external settings from interfering with Git's own Perl interpreter. This branch also cleans up some of our Windows-only config setting code (and this will need to be rearranged in the next merging rebase so that the cleanup comes first, and fscache and longPaths support build on top). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -909,6 +909,12 @@ relatively high IO latencies. When enabled, Git will do the
|
||||
index comparison to the filesystem data in parallel, allowing
|
||||
overlapping IO's. Defaults to true.
|
||||
|
||||
core.unsetenvvars::
|
||||
EXPERIMENTAL, Windows-only: comma-separated list of environment
|
||||
variables' names that need to be unset before spawning any other
|
||||
process. Defaults to `PERL5LIB` to account for the fact that Git
|
||||
for Windows insists on using its own Perl interpreter.
|
||||
|
||||
core.createObject::
|
||||
You can set this to 'link', in which case a hardlink followed by
|
||||
a delete of the source are used to make sure that object creation
|
||||
|
||||
8
cache.h
8
cache.h
@@ -901,14 +901,6 @@ int use_optional_locks(void);
|
||||
extern char comment_line_char;
|
||||
extern int auto_comment_line_char;
|
||||
|
||||
/* Windows only */
|
||||
enum hide_dotfiles_type {
|
||||
HIDE_DOTFILES_FALSE = 0,
|
||||
HIDE_DOTFILES_TRUE,
|
||||
HIDE_DOTFILES_DOTGITONLY
|
||||
};
|
||||
extern enum hide_dotfiles_type hide_dotfiles;
|
||||
|
||||
enum log_refs_config {
|
||||
LOG_REFS_UNSET = -1,
|
||||
LOG_REFS_NONE = 0,
|
||||
|
||||
@@ -202,6 +202,35 @@ static int ask_yes_no_if_possible(const char *format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
/* Windows only */
|
||||
enum hide_dotfiles_type {
|
||||
HIDE_DOTFILES_FALSE = 0,
|
||||
HIDE_DOTFILES_TRUE,
|
||||
HIDE_DOTFILES_DOTGITONLY
|
||||
};
|
||||
|
||||
static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
static char *unset_environment_variables;
|
||||
|
||||
int mingw_core_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
if (!strcmp(var, "core.hidedotfiles")) {
|
||||
if (value && !strcasecmp(value, "dotgitonly"))
|
||||
hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
else
|
||||
hide_dotfiles = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.unsetenvvars")) {
|
||||
free(unset_environment_variables);
|
||||
unset_environment_variables = xstrdup(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mingw_unlink(const char *pathname)
|
||||
{
|
||||
int ret, tries = 0;
|
||||
@@ -1080,6 +1109,27 @@ static wchar_t *make_environment_block(char **deltaenv)
|
||||
return wenvblk;
|
||||
}
|
||||
|
||||
static void do_unset_environment_variables(void)
|
||||
{
|
||||
static int done;
|
||||
char *p = unset_environment_variables;
|
||||
|
||||
if (done || !p)
|
||||
return;
|
||||
done = 1;
|
||||
|
||||
for (;;) {
|
||||
char *comma = strchr(p, ',');
|
||||
|
||||
if (comma)
|
||||
*comma = '\0';
|
||||
unsetenv(p);
|
||||
if (!comma)
|
||||
break;
|
||||
p = comma + 1;
|
||||
}
|
||||
}
|
||||
|
||||
struct pinfo_t {
|
||||
struct pinfo_t *next;
|
||||
pid_t pid;
|
||||
@@ -1098,9 +1148,12 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
|
||||
wchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs, *wenvblk = NULL;
|
||||
unsigned flags = CREATE_UNICODE_ENVIRONMENT;
|
||||
BOOL ret;
|
||||
HANDLE cons;
|
||||
|
||||
do_unset_environment_variables();
|
||||
|
||||
/* Determine whether or not we are associated to a console */
|
||||
HANDLE cons = CreateFile("CONOUT$", GENERIC_WRITE,
|
||||
cons = CreateFile("CONOUT$", GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (cons == INVALID_HANDLE_VALUE) {
|
||||
@@ -2291,6 +2344,8 @@ void mingw_startup(void)
|
||||
/* fix Windows specific environment settings */
|
||||
setup_windows_environment();
|
||||
|
||||
unset_environment_variables = xstrdup("PERL5LIB");
|
||||
|
||||
/* initialize critical section for waitpid pinfo_t list */
|
||||
InitializeCriticalSection(&pinfo_cs);
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ typedef _sigset_t sigset_t;
|
||||
#undef _POSIX_THREAD_SAFE_FUNCTIONS
|
||||
#endif
|
||||
|
||||
extern int mingw_core_config(const char *var, const char *value, void *cb);
|
||||
#define platform_core_config mingw_core_config
|
||||
|
||||
/*
|
||||
* things that are not available in header files
|
||||
*/
|
||||
|
||||
18
config.c
18
config.c
@@ -1093,7 +1093,7 @@ int git_config_color(char *dest, const char *var, const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int git_default_core_config(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")) {
|
||||
@@ -1344,14 +1344,6 @@ static int git_default_core_config(const char *var, const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.hidedotfiles")) {
|
||||
if (value && !strcasecmp(value, "dotgitonly"))
|
||||
hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
else
|
||||
hide_dotfiles = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.partialclonefilter")) {
|
||||
return git_config_string(&core_partial_clone_filter_default,
|
||||
var, value);
|
||||
@@ -1363,7 +1355,7 @@ static int git_default_core_config(const char *var, const char *value)
|
||||
}
|
||||
|
||||
/* Add other config variables here and to Documentation/config.txt. */
|
||||
return 0;
|
||||
return platform_core_config(var, value, cb);
|
||||
}
|
||||
|
||||
static int git_default_i18n_config(const char *var, const char *value)
|
||||
@@ -1448,13 +1440,13 @@ static int git_default_mailmap_config(const char *var, const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_default_config(const char *var, const char *value, void *dummy)
|
||||
int git_default_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
if (starts_with(var, "core."))
|
||||
return git_default_core_config(var, value);
|
||||
return git_default_core_config(var, value, cb);
|
||||
|
||||
if (starts_with(var, "user."))
|
||||
return git_ident_config(var, value, dummy);
|
||||
return git_ident_config(var, value, cb);
|
||||
|
||||
if (starts_with(var, "i18n."))
|
||||
return git_default_i18n_config(var, value);
|
||||
|
||||
@@ -71,7 +71,6 @@ int core_apply_sparse_checkout;
|
||||
int merge_log_config = -1;
|
||||
int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
|
||||
unsigned long pack_size_limit_cfg;
|
||||
enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
|
||||
enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;
|
||||
|
||||
#ifndef PROTECT_HFS_DEFAULT
|
||||
|
||||
@@ -342,6 +342,14 @@ typedef uintmax_t timestamp_t;
|
||||
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
|
||||
#endif
|
||||
|
||||
#ifndef platform_core_config
|
||||
static inline int noop_core_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#define platform_core_config noop_core_config
|
||||
#endif
|
||||
|
||||
#ifndef has_dos_drive_prefix
|
||||
static inline int git_has_dos_drive_prefix(const char *path)
|
||||
{
|
||||
|
||||
30
t/t0029-core-unsetenvvars.sh
Executable file
30
t/t0029-core-unsetenvvars.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='test the Windows-only core.unsetenvvars setting'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq MINGW
|
||||
then
|
||||
skip_all='skipping Windows-specific tests'
|
||||
test_done
|
||||
fi
|
||||
|
||||
test_expect_success 'setup' '
|
||||
mkdir -p "$TRASH_DIRECTORY/.git/hooks" &&
|
||||
write_script "$TRASH_DIRECTORY/.git/hooks/pre-commit" <<-\EOF
|
||||
echo $HOBBES >&2
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'core.unsetenvvars works' '
|
||||
HOBBES=Calvin &&
|
||||
export HOBBES &&
|
||||
git commit --allow-empty -m with 2>err &&
|
||||
grep Calvin err &&
|
||||
git -c core.unsetenvvars=FINDUS,HOBBES,CALVIN \
|
||||
commit --allow-empty -m without 2>err &&
|
||||
! grep Calvin err
|
||||
'
|
||||
|
||||
test_done
|
||||
Reference in New Issue
Block a user