Skip to content

Commit

Permalink
Merge branch 'msys2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dscho committed Aug 16, 2019
2 parents 7111da7 + 3e66aa1 commit 9d62a57
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
3 changes: 3 additions & 0 deletions compat/mingw.c
Expand Up @@ -2582,6 +2582,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)
Expand Down
60 changes: 59 additions & 1 deletion compat/terminal.c
@@ -1,4 +1,4 @@
#include "git-compat-util.h"
#include "cache.h"
#include "compat/terminal.h"
#include "sigchain.h"
#include "strbuf.h"
Expand Down Expand Up @@ -194,6 +194,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
Expand All @@ -206,6 +255,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;
Expand Down
8 changes: 2 additions & 6 deletions gpg-interface.c
Expand Up @@ -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);

Expand All @@ -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. */
Expand Down
13 changes: 0 additions & 13 deletions t/t7004-tag.sh
Expand Up @@ -1366,26 +1366,13 @@ 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)' \
'test_config user.signingkey BobTheMouse &&
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
Expand Down
6 changes: 6 additions & 0 deletions t/t9020-remote-svn.sh
Expand Up @@ -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
Expand Down

0 comments on commit 9d62a57

Please sign in to comment.