Skip to content

Commit

Permalink
Merge branch 'sk/mingw-uni-fix-more'
Browse files Browse the repository at this point in the history
Most of these are battle-tested in msysgit and are needed to
complete what has been merged to 'master' already.

* sk/mingw-uni-fix-more:
  Win32: enable color output in Windows cmd.exe
  Win32: patch Windows environment on startup
  Win32: keep the environment sorted
  Win32: use low-level memory allocation during initialization
  Win32: reduce environment array reallocations
  Win32: don't copy the environment twice when spawning child processes
  Win32: factor out environment block creation
  Win32: unify environment function names
  Win32: unify environment case-sensitivity
  Win32: fix environment memory leaks
  Win32: Unicode environment (incoming)
  Win32: Unicode environment (outgoing)
  Revert "Windows: teach getenv to do a case-sensitive search"
  tests: do not pass iso8859-1 encoded parameter
  • Loading branch information
gitster committed Jul 30, 2014
2 parents 4b0c0e3 + baea068 commit 385e171
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 150 deletions.
291 changes: 164 additions & 127 deletions compat/mingw.c

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ char *mingw_getcwd(char *pointer, int len);

char *mingw_getenv(const char *name);
#define getenv mingw_getenv
int mingw_putenv(const char *namevalue);
#define putenv mingw_putenv
#define unsetenv mingw_putenv

int mingw_gethostname(char *host, int namelen);
#define gethostname mingw_gethostname
Expand Down Expand Up @@ -357,12 +360,8 @@ int mingw_offset_1st_component(const char *path);
void mingw_open_html(const char *path);
#define open_html mingw_open_html

/*
* helpers
*/

char **make_augmented_environ(const char *const *vars);
void free_environ(char **env);
void mingw_mark_as_git_dir(const char *dir);
#define mark_as_git_dir mingw_mark_as_git_dir

/**
* Converts UTF-8 encoded string to UTF-16LE.
Expand Down
2 changes: 0 additions & 2 deletions config.mak.uname
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ ifeq ($(uname_S),Windows)
NO_IPV6 = YesPlease
NO_UNIX_SOCKETS = YesPlease
NO_SETENV = YesPlease
NO_UNSETENV = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_MEMMEM = YesPlease
Expand Down Expand Up @@ -480,7 +479,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_SYMLINK_HEAD = YesPlease
NO_UNIX_SOCKETS = YesPlease
NO_SETENV = YesPlease
NO_UNSETENV = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_MEMMEM = YesPlease
Expand Down
10 changes: 2 additions & 8 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ int start_command(struct child_process *cmd)
{
int fhin = 0, fhout = 1, fherr = 2;
const char **sargv = cmd->argv;
char **env = environ;

if (cmd->no_stdin)
fhin = open("/dev/null", O_RDWR);
Expand All @@ -479,24 +478,19 @@ int start_command(struct child_process *cmd)
else if (cmd->out > 1)
fhout = dup(cmd->out);

if (cmd->env)
env = make_augmented_environ(cmd->env);

if (cmd->git_cmd)
cmd->argv = prepare_git_cmd(cmd->argv);
else if (cmd->use_shell)
cmd->argv = prepare_shell_cmd(cmd->argv);

cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env, cmd->dir,
fhin, fhout, fherr);
cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, (char**) cmd->env,
cmd->dir, fhin, fhout, fherr);
failed_errno = errno;
if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
if (cmd->clean_on_exit && cmd->pid >= 0)
mark_child_for_cleanup(cmd->pid);

if (cmd->env)
free_environ(env);
if (cmd->git_cmd)
free(cmd->argv);

Expand Down
6 changes: 4 additions & 2 deletions t/t4041-diff-submodule-option.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding) &&
git -c "i18n.commitEncoding=$test_encoding" commit -m "$msg_added_iso88591"
# "git commit -m" would break MinGW, as Windows refuse to pass
# $test_encoding encoded parameter to git.
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
git -c "i18n.commitEncoding=$test_encoding" commit -F -
done >/dev/null &&
git rev-parse --short --verify HEAD
)
Expand Down
2 changes: 1 addition & 1 deletion t/t4205-log-pretty-formats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_expect_success 'set up basic repos' '
git add foo &&
test_tick &&
git config i18n.commitEncoding $test_encoding &&
git commit -m "$(commit_msg $test_encoding)" &&
commit_msg $test_encoding | git commit -F - &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
Expand Down
4 changes: 2 additions & 2 deletions t/t6006-rev-list-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ test_expect_success 'setup' '
: >foo &&
git add foo &&
git config i18n.commitEncoding $test_encoding &&
git commit -m "$added_iso88591" &&
echo "$added_iso88591" | git commit -F - &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
tree1=$(git rev-parse --verify HEAD:) &&
tree1_short=$(git rev-parse --verify --short $tree1) &&
echo "$changed" > foo &&
git commit -a -m "$changed_iso88591" &&
echo "$changed_iso88591" | git commit -a -F - &&
head2=$(git rev-parse --verify HEAD) &&
head2_short=$(git rev-parse --verify --short $head2) &&
tree2=$(git rev-parse --verify HEAD:) &&
Expand Down
8 changes: 6 additions & 2 deletions t/t7102-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ test_expect_success 'creating initial files and commits' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
# "git commit -m" would break MinGW, as Windows refuse to pass
# $test_encoding encoded parameter to git.
commit_msg $test_encoding | git -c "i18n.commitEncoding=$test_encoding" commit -a -F - &&
head5=$(git rev-parse --verify HEAD)
'
# git log --pretty=oneline # to see those SHA1 involved
Expand Down Expand Up @@ -334,7 +336,9 @@ test_expect_success 'redoing the last two commits should succeed' '
echo "1st line 2nd file" >secondfile &&
echo "2nd line 2nd file" >>secondfile &&
git -c "i18n.commitEncoding=$test_encoding" commit -a -m "$(commit_msg $test_encoding)" &&
# "git commit -m" would break MinGW, as Windows refuse to pass
# $test_encoding encoded parameter to git.
commit_msg $test_encoding | git -c "i18n.commitEncoding=$test_encoding" commit -a -F - &&
check_changes $head5
'

Expand Down

0 comments on commit 385e171

Please sign in to comment.