Skip to content

Commit a7e1673

Browse files
committed
Merge branch 'msys2'
2 parents 2c66d73 + 99580bd commit a7e1673

18 files changed

+232
-85
lines changed

Documentation/Makefile

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ docdep_prereqs = \
287287
cmd-list.made $(cmds_txt)
288288

289289
doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
290-
$(QUIET_GEN)$(RM) $@+ $@ && \
291-
$(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
292-
mv $@+ $@
290+
$(QUIET_GEN)$(RM) $@.new $@ && \
291+
$(PERL_PATH) ./build-docdep.perl >$@.new $(QUIET_STDERR) && \
292+
mv $@.new $@
293293

294294
-include doc.dep
295295

@@ -325,8 +325,8 @@ mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
325325
date >$@
326326

327327
clean:
328-
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
329-
$(RM) *.texi *.texi+ *.texi++ git.info gitman.info
328+
$(RM) *.xml *.xml.new *.html *.html.new *.1 *.5 *.7
329+
$(RM) *.texi *.texi.new *.texi.new.new git.info gitman.info
330330
$(RM) *.pdf
331331
$(RM) howto-index.txt howto/*.html doc.dep
332332
$(RM) technical/*.html technical/api-index.txt
@@ -335,14 +335,14 @@ clean:
335335
$(RM) manpage-base-url.xsl
336336

337337
$(MAN_HTML): %.html : %.txt asciidoc.conf
338-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
339-
$(TXT_TO_HTML) -d manpage -o $@+ $< && \
340-
mv $@+ $@
338+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
339+
$(TXT_TO_HTML) -d manpage -o $@.new $< && \
340+
mv $@.new $@
341341

342342
$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
343-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
344-
$(TXT_TO_HTML) -o $@+ $< && \
345-
mv $@+ $@
343+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
344+
$(TXT_TO_HTML) -o $@.new $< && \
345+
mv $@.new $@
346346

347347
manpage-base-url.xsl: manpage-base-url.xsl.in
348348
$(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
@@ -352,14 +352,14 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
352352
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
353353

354354
%.xml : %.txt asciidoc.conf
355-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
356-
$(TXT_TO_XML) -d manpage -o $@+ $< && \
357-
mv $@+ $@
355+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
356+
$(TXT_TO_XML) -d manpage -o $@.new $< && \
357+
mv $@.new $@
358358

359359
user-manual.xml: user-manual.txt user-manual.conf
360-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
361-
$(TXT_TO_XML) -d book -o $@+ $< && \
362-
mv $@+ $@
360+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
361+
$(TXT_TO_XML) -d book -o $@.new $< && \
362+
mv $@.new $@
363363

364364
technical/api-index.txt: technical/api-index-skel.txt \
365365
technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
@@ -376,46 +376,46 @@ XSLT = docbook.xsl
376376
XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
377377

378378
user-manual.html: user-manual.xml $(XSLT)
379-
$(QUIET_XSLTPROC)$(RM) $@+ $@ && \
380-
xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
381-
mv $@+ $@
379+
$(QUIET_XSLTPROC)$(RM) $@.new $@ && \
380+
xsltproc $(XSLTOPTS) -o $@.new $(XSLT) $< && \
381+
mv $@.new $@
382382

383383
git.info: user-manual.texi
384384
$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
385385

386386
user-manual.texi: user-manual.xml
387-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
388-
$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
389-
$(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
390-
rm $@++ && \
391-
mv $@+ $@
387+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
388+
$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@.new.new && \
389+
$(PERL_PATH) fix-texi.perl <$@.new.new >$@.new && \
390+
rm $@.new.new && \
391+
mv $@.new $@
392392

393393
user-manual.pdf: user-manual.xml
394-
$(QUIET_DBLATEX)$(RM) $@+ $@ && \
395-
$(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
396-
mv $@+ $@
394+
$(QUIET_DBLATEX)$(RM) $@.new $@ && \
395+
$(DBLATEX) -o $@.new $(DBLATEX_COMMON) $< && \
396+
mv $@.new $@
397397

398398
gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
399-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
400-
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
401-
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
402-
rm $(xml)+ &&) true) > $@++ && \
403-
$(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
404-
rm $@++ && \
405-
mv $@+ $@
399+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
400+
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml).new texi.xsl $(xml) && \
401+
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml).new && \
402+
rm $(xml).new &&) true) > $@.new.new && \
403+
$(PERL_PATH) cat-texi.perl $@ <$@.new.new >$@.new && \
404+
rm $@.new.new && \
405+
mv $@.new $@
406406

407407
gitman.info: gitman.texi
408408
$(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
409409

410410
$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
411-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
412-
$(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
413-
mv $@+ $@
411+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
412+
$(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@.new && \
413+
mv $@.new $@
414414

415415
howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
416-
$(QUIET_GEN)$(RM) $@+ $@ && \
417-
'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
418-
mv $@+ $@
416+
$(QUIET_GEN)$(RM) $@.new $@ && \
417+
'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@.new && \
418+
mv $@.new $@
419419

420420
$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
421421
$(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
@@ -424,10 +424,10 @@ WEBDOC_DEST = /pub/software/scm/git/docs
424424

425425
howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
426426
$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
427-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
427+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
428428
sed -e '1,/^$$/d' $< | \
429-
$(TXT_TO_HTML) - >$@+ && \
430-
mv $@+ $@
429+
$(TXT_TO_HTML) - >$@.new && \
430+
mv $@.new $@
431431

432432
install-webdoc : html
433433
'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)

builtin/clean.c

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

580+
fflush(stdout);
580581
if (strbuf_getline_lf(&choice, stdin) != EOF) {
581582
strbuf_trim(&choice);
582583
} else {
@@ -659,6 +660,7 @@ static int filter_by_patterns_cmd(void)
659660
clean_print_color(CLEAN_COLOR_PROMPT);
660661
printf(_("Input ignore patterns>> "));
661662
clean_print_color(CLEAN_COLOR_RESET);
663+
fflush(stdout);
662664
if (strbuf_getline_lf(&confirm, stdin) != EOF)
663665
strbuf_trim(&confirm);
664666
else
@@ -757,6 +759,7 @@ static int ask_each_cmd(void)
757759
qname = quote_path_relative(item->string, NULL, &buf);
758760
/* TRANSLATORS: Make sure to keep [y/N] as is */
759761
printf(_("Remove %s [y/N]? "), qname);
762+
fflush(stdout);
760763
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
761764
strbuf_trim(&confirm);
762765
} else {

compat/mingw.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14101410
HANDLE cons;
14111411
const char *(*quote_arg)(const char *arg) =
14121412
is_msys2_sh(*argv) ? quote_arg_msys2 : quote_arg_msvc;
1413+
const char *strace_env;
14131414

14141415
do_unset_environment_variables();
14151416

@@ -1467,6 +1468,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14671468
free(quoted);
14681469
}
14691470

1471+
strace_env = getenv("GIT_STRACE_COMMANDS");
1472+
if (strace_env) {
1473+
char *p = path_lookup("strace.exe", 1);
1474+
if (!p)
1475+
return error("strace not found!");
1476+
if (xutftowcs_path(wcmd, p) < 0) {
1477+
free(p);
1478+
return -1;
1479+
}
1480+
free(p);
1481+
if (!strcmp("1", strace_env) ||
1482+
!strcasecmp("yes", strace_env) ||
1483+
!strcasecmp("true", strace_env))
1484+
strbuf_insert(&args, 0, "strace ", 7);
1485+
else {
1486+
const char *quoted = quote_arg(strace_env);
1487+
struct strbuf buf = STRBUF_INIT;
1488+
strbuf_addf(&buf, "strace -o %s ", quoted);
1489+
if (quoted != strace_env)
1490+
free((char *)quoted);
1491+
strbuf_insert(&args, 0, buf.buf, buf.len);
1492+
strbuf_release(&buf);
1493+
}
1494+
}
1495+
14701496
ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1));
14711497
xutftowcs(wargs, args.buf, 2 * args.len + 1);
14721498
strbuf_release(&args);
@@ -2527,6 +2553,33 @@ static void setup_windows_environment(void)
25272553
/* simulate TERM to enable auto-color (see color.c) */
25282554
if (!getenv("TERM"))
25292555
setenv("TERM", "cygwin", 1);
2556+
2557+
/* calculate HOME if not set */
2558+
if (!getenv("HOME")) {
2559+
/*
2560+
* try $HOMEDRIVE$HOMEPATH - the home share may be a network
2561+
* location, thus also check if the path exists (i.e. is not
2562+
* disconnected)
2563+
*/
2564+
if ((tmp = getenv("HOMEDRIVE"))) {
2565+
struct strbuf buf = STRBUF_INIT;
2566+
strbuf_addstr(&buf, tmp);
2567+
if ((tmp = getenv("HOMEPATH"))) {
2568+
strbuf_addstr(&buf, tmp);
2569+
if (is_directory(buf.buf))
2570+
setenv("HOME", buf.buf, 1);
2571+
else
2572+
tmp = NULL; /* use $USERPROFILE */
2573+
}
2574+
strbuf_release(&buf);
2575+
}
2576+
/* use $USERPROFILE if the home share is not available */
2577+
if (!tmp && (tmp = getenv("USERPROFILE")))
2578+
setenv("HOME", tmp, 1);
2579+
}
2580+
2581+
if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
2582+
setenv("LC_CTYPE", "C", 1);
25302583
}
25312584

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

compat/terminal.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
#ifndef NO_INTTYPES_H
2+
#include <inttypes.h>
3+
#endif
14
#include "git-compat-util.h"
5+
#include "run-command.h"
26
#include "compat/terminal.h"
37
#include "sigchain.h"
48
#include "strbuf.h"
9+
#include "cache.h"
510

611
#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
712

@@ -91,6 +96,55 @@ static int disable_echo(void)
9196
return 0;
9297
}
9398

99+
static char *shell_prompt(const char *prompt, int echo)
100+
{
101+
const char *read_input[] = {
102+
/* Note: call 'bash' explicitly, as 'read -s' is bash-specific */
103+
"bash", "-c", echo ?
104+
"cat >/dev/tty && read -r line </dev/tty && echo \"$line\"" :
105+
"cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo >/dev/tty",
106+
NULL
107+
};
108+
struct child_process child = CHILD_PROCESS_INIT;
109+
static struct strbuf buffer = STRBUF_INIT;
110+
int prompt_len = strlen(prompt), len = -1, code;
111+
112+
child.argv = read_input;
113+
child.in = -1;
114+
child.out = -1;
115+
child.silent_exec_failure = 1;
116+
117+
if (start_command(&child))
118+
return NULL;
119+
120+
if (write_in_full(child.in, prompt, prompt_len) != prompt_len) {
121+
error("could not write to prompt script");
122+
close(child.in);
123+
goto ret;
124+
}
125+
close(child.in);
126+
127+
strbuf_reset(&buffer);
128+
len = strbuf_read(&buffer, child.out, 1024);
129+
if (len < 0) {
130+
error("could not read from prompt script");
131+
goto ret;
132+
}
133+
134+
strbuf_strip_suffix(&buffer, "\n");
135+
strbuf_strip_suffix(&buffer, "\r");
136+
137+
ret:
138+
close(child.out);
139+
code = finish_command(&child);
140+
if (code) {
141+
error("failed to execute prompt script (exit code %d)", code);
142+
return NULL;
143+
}
144+
145+
return len < 0 ? NULL : buffer.buf;
146+
}
147+
94148
#endif
95149

96150
#ifndef FORCE_TEXT
@@ -103,6 +157,15 @@ char *git_terminal_prompt(const char *prompt, int echo)
103157
int r;
104158
FILE *input_fh, *output_fh;
105159

160+
#ifdef GIT_WINDOWS_NATIVE
161+
162+
/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
163+
char *result = shell_prompt(prompt, echo);
164+
if (result || errno != ENOENT)
165+
return result;
166+
167+
#endif
168+
106169
input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
107170
if (!input_fh)
108171
return NULL;

compat/win32/git.manifest

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity type="win32" name="Git" version="0.0.0.1" />
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges>
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
8+
</requestedPrivileges>
9+
</security>
10+
</trustInfo>
11+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
12+
<application>
13+
<!-- Windows Vista -->
14+
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
15+
<!-- Windows 7 -->
16+
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
17+
<!-- Windows 8 -->
18+
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
19+
<!-- Windows 8.1 -->
20+
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
21+
<!-- Windows 10 -->
22+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
23+
</application>
24+
</compatibility>
25+
</assembly>

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 */

0 commit comments

Comments
 (0)