Skip to content

Commit d2e4630

Browse files
committed
Merge branch 'msys2'
2 parents a410f8a + 7c6da2c commit d2e4630

17 files changed

+226
-84
lines changed

Documentation/Makefile

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

296296
doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
297-
$(QUIET_GEN)$(RM) $@+ $@ && \
298-
$(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
299-
mv $@+ $@
297+
$(QUIET_GEN)$(RM) $@.new $@ && \
298+
$(PERL_PATH) ./build-docdep.perl >$@.new $(QUIET_STDERR) && \
299+
mv $@.new $@
300300

301301
-include doc.dep
302302

@@ -332,8 +332,8 @@ mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
332332
date >$@
333333

334334
clean:
335-
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
336-
$(RM) *.texi *.texi+ *.texi++ git.info gitman.info
335+
$(RM) *.xml *.xml.new *.html *.html.new *.1 *.5 *.7
336+
$(RM) *.texi *.texi.new *.texi.new.new git.info gitman.info
337337
$(RM) *.pdf
338338
$(RM) howto-index.txt howto/*.html doc.dep
339339
$(RM) technical/*.html technical/api-index.txt
@@ -342,14 +342,14 @@ clean:
342342
$(RM) manpage-base-url.xsl
343343

344344
$(MAN_HTML): %.html : %.txt asciidoc.conf
345-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
346-
$(TXT_TO_HTML) -d manpage -o $@+ $< && \
347-
mv $@+ $@
345+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
346+
$(TXT_TO_HTML) -d manpage -o $@.new $< && \
347+
mv $@.new $@
348348

349349
$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
350-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
351-
$(TXT_TO_HTML) -o $@+ $< && \
352-
mv $@+ $@
350+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
351+
$(TXT_TO_HTML) -o $@.new $< && \
352+
mv $@.new $@
353353

354354
manpage-base-url.xsl: manpage-base-url.xsl.in
355355
$(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
@@ -359,14 +359,14 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
359359
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
360360

361361
%.xml : %.txt asciidoc.conf
362-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
363-
$(TXT_TO_XML) -d manpage -o $@+ $< && \
364-
mv $@+ $@
362+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
363+
$(TXT_TO_XML) -d manpage -o $@.new $< && \
364+
mv $@.new $@
365365

366366
user-manual.xml: user-manual.txt user-manual.conf
367-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
368-
$(TXT_TO_XML) -d book -o $@+ $< && \
369-
mv $@+ $@
367+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
368+
$(TXT_TO_XML) -d book -o $@.new $< && \
369+
mv $@.new $@
370370

371371
technical/api-index.txt: technical/api-index-skel.txt \
372372
technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
@@ -383,46 +383,46 @@ XSLT = docbook.xsl
383383
XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
384384

385385
user-manual.html: user-manual.xml $(XSLT)
386-
$(QUIET_XSLTPROC)$(RM) $@+ $@ && \
387-
xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
388-
mv $@+ $@
386+
$(QUIET_XSLTPROC)$(RM) $@.new $@ && \
387+
xsltproc $(XSLTOPTS) -o $@.new $(XSLT) $< && \
388+
mv $@.new $@
389389

390390
git.info: user-manual.texi
391391
$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
392392

393393
user-manual.texi: user-manual.xml
394-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
395-
$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
396-
$(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
397-
rm $@++ && \
398-
mv $@+ $@
394+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
395+
$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@.new.new && \
396+
$(PERL_PATH) fix-texi.perl <$@.new.new >$@.new && \
397+
rm $@.new.new && \
398+
mv $@.new $@
399399

400400
user-manual.pdf: user-manual.xml
401-
$(QUIET_DBLATEX)$(RM) $@+ $@ && \
402-
$(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
403-
mv $@+ $@
401+
$(QUIET_DBLATEX)$(RM) $@.new $@ && \
402+
$(DBLATEX) -o $@.new $(DBLATEX_COMMON) $< && \
403+
mv $@.new $@
404404

405405
gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
406-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
407-
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
408-
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
409-
rm $(xml)+ &&) true) > $@++ && \
410-
$(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
411-
rm $@++ && \
412-
mv $@+ $@
406+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
407+
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml).new texi.xsl $(xml) && \
408+
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml).new && \
409+
rm $(xml).new &&) true) > $@.new.new && \
410+
$(PERL_PATH) cat-texi.perl $@ <$@.new.new >$@.new && \
411+
rm $@.new.new && \
412+
mv $@.new $@
413413

414414
gitman.info: gitman.texi
415415
$(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
416416

417417
$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
418-
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
419-
$(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
420-
mv $@+ $@
418+
$(QUIET_DB2TEXI)$(RM) $@.new $@ && \
419+
$(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@.new && \
420+
mv $@.new $@
421421

422422
howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
423-
$(QUIET_GEN)$(RM) $@+ $@ && \
424-
'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
425-
mv $@+ $@
423+
$(QUIET_GEN)$(RM) $@.new $@ && \
424+
'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@.new && \
425+
mv $@.new $@
426426

427427
$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
428428
$(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
@@ -431,10 +431,10 @@ WEBDOC_DEST = /pub/software/scm/git/docs
431431

432432
howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
433433
$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
434-
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
434+
$(QUIET_ASCIIDOC)$(RM) $@.new $@ && \
435435
sed -e '1,/^$$/d' $< | \
436-
$(TXT_TO_HTML) - >$@+ && \
437-
mv $@+ $@
436+
$(TXT_TO_HTML) - >$@.new && \
437+
mv $@.new $@
438438

439439
install-webdoc : html
440440
'$(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
@@ -578,6 +578,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
578578
clean_get_color(CLEAN_COLOR_RESET));
579579
}
580580

581+
fflush(stdout);
581582
if (strbuf_getline_lf(&choice, stdin) != EOF) {
582583
strbuf_trim(&choice);
583584
} else {
@@ -660,6 +661,7 @@ static int filter_by_patterns_cmd(void)
660661
clean_print_color(CLEAN_COLOR_PROMPT);
661662
printf(_("Input ignore patterns>> "));
662663
clean_print_color(CLEAN_COLOR_RESET);
664+
fflush(stdout);
663665
if (strbuf_getline_lf(&confirm, stdin) != EOF)
664666
strbuf_trim(&confirm);
665667
else
@@ -758,6 +760,7 @@ static int ask_each_cmd(void)
758760
qname = quote_path_relative(item->string, NULL, &buf);
759761
/* TRANSLATORS: Make sure to keep [y/N] as is */
760762
printf(_("Remove %s [y/N]? "), qname);
763+
fflush(stdout);
761764
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
762765
strbuf_trim(&confirm);
763766
} else {

compat/mingw.c

Lines changed: 53 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

@@ -1494,6 +1495,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14941495
free(quoted);
14951496
}
14961497

1498+
strace_env = getenv("GIT_STRACE_COMMANDS");
1499+
if (strace_env) {
1500+
char *p = path_lookup("strace.exe", 1);
1501+
if (!p)
1502+
return error("strace not found!");
1503+
if (xutftowcs_path(wcmd, p) < 0) {
1504+
free(p);
1505+
return -1;
1506+
}
1507+
free(p);
1508+
if (!strcmp("1", strace_env) ||
1509+
!strcasecmp("yes", strace_env) ||
1510+
!strcasecmp("true", strace_env))
1511+
strbuf_insert(&args, 0, "strace ", 7);
1512+
else {
1513+
const char *quoted = quote_arg(strace_env);
1514+
struct strbuf buf = STRBUF_INIT;
1515+
strbuf_addf(&buf, "strace -o %s ", quoted);
1516+
if (quoted != strace_env)
1517+
free((char *)quoted);
1518+
strbuf_insert(&args, 0, buf.buf, buf.len);
1519+
strbuf_release(&buf);
1520+
}
1521+
}
1522+
14971523
ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1));
14981524
xutftowcs(wargs, args.buf, 2 * args.len + 1);
14991525
strbuf_release(&args);
@@ -2355,6 +2381,33 @@ static void setup_windows_environment(void)
23552381
/* simulate TERM to enable auto-color (see color.c) */
23562382
if (!getenv("TERM"))
23572383
setenv("TERM", "cygwin", 1);
2384+
2385+
/* calculate HOME if not set */
2386+
if (!getenv("HOME")) {
2387+
/*
2388+
* try $HOMEDRIVE$HOMEPATH - the home share may be a network
2389+
* location, thus also check if the path exists (i.e. is not
2390+
* disconnected)
2391+
*/
2392+
if ((tmp = getenv("HOMEDRIVE"))) {
2393+
struct strbuf buf = STRBUF_INIT;
2394+
strbuf_addstr(&buf, tmp);
2395+
if ((tmp = getenv("HOMEPATH"))) {
2396+
strbuf_addstr(&buf, tmp);
2397+
if (is_directory(buf.buf))
2398+
setenv("HOME", buf.buf, 1);
2399+
else
2400+
tmp = NULL; /* use $USERPROFILE */
2401+
}
2402+
strbuf_release(&buf);
2403+
}
2404+
/* use $USERPROFILE if the home share is not available */
2405+
if (!tmp && (tmp = getenv("USERPROFILE")))
2406+
setenv("HOME", tmp, 1);
2407+
}
2408+
2409+
if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
2410+
setenv("LC_CTYPE", "C", 1);
23582411
}
23592412

23602413
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)