Skip to content

Commit 60fed10

Browse files
committed
Merge branch 'msys2'
2 parents ff49792 + 353f99d commit 60fed10

12 files changed

+117
-37
lines changed

builtin/clean.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
579579
clean_get_color(CLEAN_COLOR_RESET));
580580
}
581581

582+
fflush(stdout);
582583
if (strbuf_getline_lf(&choice, stdin) != EOF) {
583584
strbuf_trim(&choice);
584585
} else {
@@ -661,6 +662,7 @@ static int filter_by_patterns_cmd(void)
661662
clean_print_color(CLEAN_COLOR_PROMPT);
662663
printf(_("Input ignore patterns>> "));
663664
clean_print_color(CLEAN_COLOR_RESET);
665+
fflush(stdout);
664666
if (strbuf_getline_lf(&confirm, stdin) != EOF)
665667
strbuf_trim(&confirm);
666668
else
@@ -759,6 +761,7 @@ static int ask_each_cmd(void)
759761
qname = quote_path_relative(item->string, NULL, &buf);
760762
/* TRANSLATORS: Make sure to keep [y/N] as is */
761763
printf(_("Remove %s [y/N]? "), qname);
764+
fflush(stdout);
762765
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
763766
strbuf_trim(&confirm);
764767
} else {

compat/mingw.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14371437
HANDLE cons;
14381438
const char *(*quote_arg)(const char *arg) =
14391439
is_msys2_sh(*argv) ? quote_arg_msys2 : quote_arg_msvc;
1440+
const char *strace_env;
14401441

14411442
do_unset_environment_variables();
14421443

@@ -1499,6 +1500,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14991500
free(quoted);
15001501
}
15011502

1503+
strace_env = getenv("GIT_STRACE_COMMANDS");
1504+
if (strace_env) {
1505+
char *p = path_lookup("strace.exe", 1);
1506+
if (!p)
1507+
return error("strace not found!");
1508+
if (xutftowcs_path(wcmd, p) < 0) {
1509+
free(p);
1510+
return -1;
1511+
}
1512+
free(p);
1513+
if (!strcmp("1", strace_env) ||
1514+
!strcasecmp("yes", strace_env) ||
1515+
!strcasecmp("true", strace_env))
1516+
strbuf_insert(&args, 0, "strace ", 7);
1517+
else {
1518+
const char *quoted = quote_arg(strace_env);
1519+
struct strbuf buf = STRBUF_INIT;
1520+
strbuf_addf(&buf, "strace -o %s ", quoted);
1521+
if (quoted != strace_env)
1522+
free((char *)quoted);
1523+
strbuf_insert(&args, 0, buf.buf, buf.len);
1524+
strbuf_release(&buf);
1525+
}
1526+
}
1527+
15021528
ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1));
15031529
xutftowcs(wargs, args.buf, 2 * args.len + 1);
15041530
strbuf_release(&args);
@@ -2395,6 +2421,9 @@ static void setup_windows_environment(void)
23952421
if (!tmp && (tmp = getenv("USERPROFILE")))
23962422
setenv("HOME", tmp, 1);
23972423
}
2424+
2425+
if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
2426+
setenv("LC_CTYPE", "C", 1);
23982427
}
23992428

24002429
int handle_long_path(wchar_t *path, int len, int max_path, int expand)

compat/terminal.c

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "git-compat-util.h"
1+
#include "cache.h"
22
#include "compat/terminal.h"
33
#include "sigchain.h"
44
#include "strbuf.h"
@@ -194,6 +194,55 @@ static int mingw_getchar(void)
194194
}
195195
#define getchar mingw_getchar
196196

197+
static char *shell_prompt(const char *prompt, int echo)
198+
{
199+
const char *read_input[] = {
200+
/* Note: call 'bash' explicitly, as 'read -s' is bash-specific */
201+
"bash", "-c", echo ?
202+
"cat >/dev/tty && read -r line </dev/tty && echo \"$line\"" :
203+
"cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo >/dev/tty",
204+
NULL
205+
};
206+
struct child_process child = CHILD_PROCESS_INIT;
207+
static struct strbuf buffer = STRBUF_INIT;
208+
int prompt_len = strlen(prompt), len = -1, code;
209+
210+
child.argv = read_input;
211+
child.in = -1;
212+
child.out = -1;
213+
child.silent_exec_failure = 1;
214+
215+
if (start_command(&child))
216+
return NULL;
217+
218+
if (write_in_full(child.in, prompt, prompt_len) != prompt_len) {
219+
error("could not write to prompt script");
220+
close(child.in);
221+
goto ret;
222+
}
223+
close(child.in);
224+
225+
strbuf_reset(&buffer);
226+
len = strbuf_read(&buffer, child.out, 1024);
227+
if (len < 0) {
228+
error("could not read from prompt script");
229+
goto ret;
230+
}
231+
232+
strbuf_strip_suffix(&buffer, "\n");
233+
strbuf_strip_suffix(&buffer, "\r");
234+
235+
ret:
236+
close(child.out);
237+
code = finish_command(&child);
238+
if (code) {
239+
error("failed to execute prompt script (exit code %d)", code);
240+
return NULL;
241+
}
242+
243+
return len < 0 ? NULL : buffer.buf;
244+
}
245+
197246
#endif
198247

199248
#ifndef FORCE_TEXT
@@ -206,6 +255,15 @@ char *git_terminal_prompt(const char *prompt, int echo)
206255
int r;
207256
FILE *input_fh, *output_fh;
208257

258+
#ifdef GIT_WINDOWS_NATIVE
259+
260+
/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
261+
char *result = shell_prompt(prompt, echo);
262+
if (result || errno != ENOENT)
263+
return result;
264+
265+
#endif
266+
209267
input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
210268
if (!input_fh)
211269
return NULL;

compat/winansi.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <wingdi.h>
88
#include <winreg.h>
99
#include "win32.h"
10+
#include "win32/lazyload.h"
1011

1112
static int fd_is_interactive[3] = { 0, 0, 0 };
1213
#define FD_CONSOLE 0x1
@@ -41,26 +42,21 @@ typedef struct _CONSOLE_FONT_INFOEX {
4142
#endif
4243
#endif
4344

44-
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
45-
PCONSOLE_FONT_INFOEX);
46-
4745
static void warn_if_raster_font(void)
4846
{
4947
DWORD fontFamily = 0;
50-
PGETCURRENTCONSOLEFONTEX pGetCurrentConsoleFontEx;
48+
DECLARE_PROC_ADDR(kernel32.dll, BOOL, GetCurrentConsoleFontEx,
49+
HANDLE, BOOL, PCONSOLE_FONT_INFOEX);
5150

5251
/* don't bother if output was ascii only */
5352
if (!non_ascii_used)
5453
return;
5554

5655
/* GetCurrentConsoleFontEx is available since Vista */
57-
pGetCurrentConsoleFontEx = (PGETCURRENTCONSOLEFONTEX) GetProcAddress(
58-
GetModuleHandle("kernel32.dll"),
59-
"GetCurrentConsoleFontEx");
60-
if (pGetCurrentConsoleFontEx) {
56+
if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
6157
CONSOLE_FONT_INFOEX cfi;
6258
cfi.cbSize = sizeof(cfi);
63-
if (pGetCurrentConsoleFontEx(console, 0, &cfi))
59+
if (GetCurrentConsoleFontEx(console, 0, &cfi))
6460
fontFamily = cfi.FontFamily;
6561
} else {
6662
/* pre-Vista: check default console font in registry */

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ else
668668
NO_LIBPCRE1_JIT = UnfortunatelyYes
669669
NO_CURL =
670670
USE_NED_ALLOCATOR = YesPlease
671+
NO_PYTHON =
671672
else
672673
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
673674
NO_CURL = YesPlease

gpg-interface.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,9 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
293293
struct child_process gpg = CHILD_PROCESS_INIT;
294294
int ret;
295295
size_t i, j, bottom;
296-
struct strbuf gpg_status = STRBUF_INIT;
297296

298297
argv_array_pushl(&gpg.args,
299298
use_format->program,
300-
"--status-fd=2",
301299
"-bsau", signing_key,
302300
NULL);
303301

@@ -309,12 +307,10 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
309307
*/
310308
sigchain_push(SIGPIPE, SIG_IGN);
311309
ret = pipe_command(&gpg, buffer->buf, buffer->len,
312-
signature, 1024, &gpg_status, 0);
310+
signature, 1024, NULL, 0);
313311
sigchain_pop(SIGPIPE);
314312

315-
ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
316-
strbuf_release(&gpg_status);
317-
if (ret)
313+
if (ret || signature->len == bottom)
318314
return error(_("gpg failed to sign the data"));
319315

320316
/* Strip CR from the line endings, in case we are on Windows. */

t/t0001-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
413413
# Tests for the hidden file attribute on windows
414414
is_hidden () {
415415
# Use the output of `attrib`, ignore the absolute path
416-
case "$(attrib "$1")" in *H*?:*) return 0;; esac
416+
case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
417417
return 1
418418
}
419419

t/t5611-clone-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
9595
# Tests for the hidden file attribute on windows
9696
is_hidden () {
9797
# Use the output of `attrib`, ignore the absolute path
98-
case "$(attrib "$1")" in *H*?:*) return 0;; esac
98+
case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
9999
return 1
100100
}
101101

t/t7004-tag.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,26 +1345,13 @@ test_expect_success GPG \
13451345
'test_config user.signingkey BobTheMouse &&
13461346
test_must_fail git tag -s -m tail tag-gpg-failure'
13471347

1348-
# try to produce invalid signature
1349-
test_expect_success GPG \
1350-
'git tag -s fails if gpg is misconfigured (bad signature format)' \
1351-
'test_config gpg.program echo &&
1352-
test_must_fail git tag -s -m tail tag-gpg-failure'
1353-
13541348
# try to sign with bad user.signingkey
13551349
test_expect_success GPGSM \
13561350
'git tag -s fails if gpgsm is misconfigured (bad key)' \
13571351
'test_config user.signingkey BobTheMouse &&
13581352
test_config gpg.format x509 &&
13591353
test_must_fail git tag -s -m tail tag-gpg-failure'
13601354

1361-
# try to produce invalid signature
1362-
test_expect_success GPGSM \
1363-
'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
1364-
'test_config gpg.x509.program echo &&
1365-
test_config gpg.format x509 &&
1366-
test_must_fail git tag -s -m tail tag-gpg-failure'
1367-
13681355
# try to verify without gpg:
13691356

13701357
rm -rf gpghome

t/t9001-send-email.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,8 @@ test_expect_success $PREREQ 'in-reply-to but no threading' '
11941194
11951195
--in-reply-to="<[email protected]>" \
11961196
--no-thread \
1197-
$patches |
1198-
grep "In-Reply-To: <[email protected]>"
1197+
$patches >out &&
1198+
grep "In-Reply-To: <[email protected]>" out
11991199
'
12001200

12011201
test_expect_success $PREREQ 'no in-reply-to and no threading' '

t/t9020-remote-svn.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ then
1212
test_done
1313
fi
1414

15+
if test_have_prereq MINGW
16+
then
17+
skip_all='skipping remote-svn tests for lack of POSIX'
18+
test_done
19+
fi
20+
1521
# Override svnrdump with our simulator
1622
PATH="$HOME:$PATH"
1723
export PATH PYTHON_PATH GIT_BUILD_DIR

t/t9116-git-svn-log.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ test_expect_success 'setup repository and import' '
4343

4444
test_expect_success 'run log' "
4545
git reset --hard origin/a &&
46-
git svn log -r2 origin/trunk | grep ^r2 &&
47-
git svn log -r4 origin/trunk | grep ^r4 &&
48-
git svn log -r3 | grep ^r3
46+
git svn log -r2 origin/trunk >out &&
47+
grep ^r2 out &&
48+
git svn log -r4 origin/trunk >out &&
49+
grep ^r4 out &&
50+
git svn log -r3 >out &&
51+
grep ^r3 out
4952
"
5053

5154
test_expect_success 'run log against a from trunk' "
5255
git reset --hard origin/trunk &&
53-
git svn log -r3 origin/a | grep ^r3
56+
git svn log -r3 origin/a >out &&
57+
grep ^r3 out
5458
"
5559

5660
printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4

0 commit comments

Comments
 (0)