Merge branch 'msys2'

This commit is contained in:
Johannes Schindelin
2018-11-15 12:23:43 +01:00
5 changed files with 70 additions and 20 deletions

View File

@@ -2577,6 +2577,9 @@ static void setup_windows_environment(void)
if (!tmp && (tmp = getenv("USERPROFILE")))
setenv("HOME", tmp, 1);
}
if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
setenv("LC_CTYPE", "C", 1);
}
int handle_long_path(wchar_t *path, int len, int max_path, int expand)

View File

@@ -1,4 +1,4 @@
#include "git-compat-util.h"
#include "cache.h"
#include "compat/terminal.h"
#include "sigchain.h"
#include "strbuf.h"
@@ -193,6 +193,55 @@ static int mingw_getchar(void)
}
#define getchar mingw_getchar
static char *shell_prompt(const char *prompt, int echo)
{
const char *read_input[] = {
/* Note: call 'bash' explicitly, as 'read -s' is bash-specific */
"bash", "-c", echo ?
"cat >/dev/tty && read -r line </dev/tty && echo \"$line\"" :
"cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo >/dev/tty",
NULL
};
struct child_process child = CHILD_PROCESS_INIT;
static struct strbuf buffer = STRBUF_INIT;
int prompt_len = strlen(prompt), len = -1, code;
child.argv = read_input;
child.in = -1;
child.out = -1;
child.silent_exec_failure = 1;
if (start_command(&child))
return NULL;
if (write_in_full(child.in, prompt, prompt_len) != prompt_len) {
error("could not write to prompt script");
close(child.in);
goto ret;
}
close(child.in);
strbuf_reset(&buffer);
len = strbuf_read(&buffer, child.out, 1024);
if (len < 0) {
error("could not read from prompt script");
goto ret;
}
strbuf_strip_suffix(&buffer, "\n");
strbuf_strip_suffix(&buffer, "\r");
ret:
close(child.out);
code = finish_command(&child);
if (code) {
error("failed to execute prompt script (exit code %d)", code);
return NULL;
}
return len < 0 ? NULL : buffer.buf;
}
#endif
#ifndef FORCE_TEXT
@@ -205,6 +254,15 @@ char *git_terminal_prompt(const char *prompt, int echo)
int r;
FILE *input_fh, *output_fh;
#ifdef GIT_WINDOWS_NATIVE
/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
char *result = shell_prompt(prompt, echo);
if (result)
return result;
#endif
input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
if (!input_fh)
return NULL;

View File

@@ -296,11 +296,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
struct child_process gpg = CHILD_PROCESS_INIT;
int ret;
size_t i, j, bottom;
struct strbuf gpg_status = STRBUF_INIT;
argv_array_pushl(&gpg.args,
use_format->program,
"--status-fd=2",
"-bsau", signing_key,
NULL);
@@ -312,12 +310,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
*/
sigchain_push(SIGPIPE, SIG_IGN);
ret = pipe_command(&gpg, buffer->buf, buffer->len,
signature, 1024, &gpg_status, 0);
signature, 1024, NULL, 0);
sigchain_pop(SIGPIPE);
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
strbuf_release(&gpg_status);
if (ret)
if (ret || signature->len == bottom)
return error(_("gpg failed to sign the data"));
/* Strip CR from the line endings, in case we are on Windows. */

View File

@@ -1366,12 +1366,6 @@ test_expect_success GPG \
'test_config user.signingkey BobTheMouse &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to produce invalid signature
test_expect_success GPG \
'git tag -s fails if gpg is misconfigured (bad signature format)' \
'test_config gpg.program echo &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to sign with bad user.signingkey
test_expect_success GPGSM \
'git tag -s fails if gpgsm is misconfigured (bad key)' \
@@ -1379,13 +1373,6 @@ test_expect_success GPGSM \
test_config gpg.format x509 &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to produce invalid signature
test_expect_success GPGSM \
'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
'test_config gpg.x509.program echo &&
test_config gpg.format x509 &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to verify without gpg:
rm -rf gpghome

View File

@@ -12,6 +12,12 @@ then
test_done
fi
if test_have_prereq MINGW
then
skip_all='skipping remote-svn tests for lack of POSIX'
test_done
fi
# Override svnrdump with our simulator
PATH="$HOME:$PATH"
export PATH PYTHON_PATH GIT_BUILD_DIR