summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-04-08 22:23:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-04-08 22:23:42 (GMT)
commit8b2b2a95f8fbd50a5769b2dc7e4d8c86d65e9660 (patch)
tree8b063422ca805bb7a7510cfc8faba48bd5752d76
parent5e55a9fd3142a7407ab7a2aa101718c4cb19b5ee (diff)
parent2bbd5b39747add41e75864ca4e3c60637ad5541a (diff)
downloadgit-pu.zip
git-pu.tar.gz
git-pu.tar.bz2
Merge branch 'js/mingw-fixes' into pupu
* js/mingw-fixes: clean: explicitly `fflush` stdout mingw: make is_hidden tests in t0001/t5611 more robust mingw: do not treat `COM0` as a reserved file name mingw: use modern strftime implementation if possible
-rw-r--r--builtin/clean.c3
-rw-r--r--compat/mingw.c19
-rwxr-xr-xt/t0001-init.sh2
-rwxr-xr-xt/t0060-path-utils.sh2
-rwxr-xr-xt/t5611-clone-config.sh2
5 files changed, 22 insertions, 6 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index b189b7b..9907ebf 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -580,6 +580,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
clean_get_color(CLEAN_COLOR_RESET));
}
+ fflush(stdout);
if (strbuf_getline_lf(&choice, stdin) != EOF) {
strbuf_trim(&choice);
} else {
@@ -662,6 +663,7 @@ static int filter_by_patterns_cmd(void)
clean_print_color(CLEAN_COLOR_PROMPT);
printf(_("Input ignore patterns>> "));
clean_print_color(CLEAN_COLOR_RESET);
+ fflush(stdout);
if (strbuf_getline_lf(&confirm, stdin) != EOF)
strbuf_trim(&confirm);
else
@@ -760,6 +762,7 @@ static int ask_each_cmd(void)
qname = quote_path_relative(item->string, NULL, &buf);
/* TRANSLATORS: Make sure to keep [y/N] as is */
printf(_("Remove %s [y/N]? "), qname);
+ fflush(stdout);
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
strbuf_trim(&confirm);
} else {
diff --git a/compat/mingw.c b/compat/mingw.c
index d14065d..f2c94f9 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -964,7 +964,16 @@ revert_attrs:
size_t mingw_strftime(char *s, size_t max,
const char *format, const struct tm *tm)
{
- size_t ret = strftime(s, max, format, tm);
+ /* a pointer to the original strftime in case we can't find the UCRT version */
+ static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
+ size_t ret;
+ DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t,
+ const char *, const struct tm *);
+
+ if (INIT_PROC_ADDR(strftime))
+ ret = strftime(s, max, format, tm);
+ else
+ ret = fallback(s, max, format, tm);
if (!ret && errno == EINVAL)
die("invalid strftime format: '%s'", format);
@@ -2581,12 +2590,14 @@ not_a_reserved_name:
continue;
}
break;
- case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */
+ case 'c': case 'C':
+ /* COM1 ... COM9, CON, CONIN$, CONOUT$ */
if ((c = path[++i]) != 'o' && c != 'O')
goto not_a_reserved_name;
c = path[++i];
- if (c == 'm' || c == 'M') { /* COM<N> */
- if (!isdigit(path[++i]))
+ if (c == 'm' || c == 'M') { /* COM1 ... COM9 */
+ c = path[++i];
+ if (c < '1' || c > '9')
goto not_a_reserved_name;
} else if (c == 'n' || c == 'N') { /* CON */
c = path[i + 1];
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 26f8206..2456688 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -395,7 +395,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
# Tests for the hidden file attribute on windows
is_hidden () {
# Use the output of `attrib`, ignore the absolute path
- case "$(attrib "$1")" in *H*?:*) return 0;; esac
+ case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
return 1
}
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 2ea2d00..56db5c8 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -476,6 +476,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
C:\\git \
comm \
conout.c \
+ com0.c \
lptN \
\
--not \
@@ -488,6 +489,7 @@ test_expect_success MINGW 'is_valid_path() on Windows' '
"AUX.c" \
"abc/conOut\$ .xyz/test" \
lpt8 \
+ com9.c \
"lpt*" \
Nul \
"PRN./abc"
diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh
index 60c1ba9..87b8073 100755
--- a/t/t5611-clone-config.sh
+++ b/t/t5611-clone-config.sh
@@ -95,7 +95,7 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
# Tests for the hidden file attribute on windows
is_hidden () {
# Use the output of `attrib`, ignore the absolute path
- case "$(attrib "$1")" in *H*?:*) return 0;; esac
+ case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
return 1
}