git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 1/2] mingw: verify that paths are not mistaken for remote nicknames
Date: Mon, 29 May 2017 22:25:25 +0200	[thread overview]
Message-ID: <17b3d445-0cc7-2000-dc67-11fb53c7040b@kdbg.org> (raw)
In-Reply-To: <20170526033510.1793-14-gitster@pobox.com>

Am 26.05.2017 um 05:35 schrieb Junio C Hamano:
> When asked to open/fopen a path, e.g. "a/b:/c", which does not exist
> on the filesystem, Windows (correctly) fails to open it but sets
> EINVAL to errno because the pathname has characters that cannot be
> stored in its filesystem.
> 
> As this is an expected failure, teach is_missing_file_error() helper
> about this case.
> 
> This is RFC, as there may be a case where we get EINVAL from
> open/fopen for reasons other than "the filesystem does not like this
> pathname" that may be worth reporting to the user, and this change
> is sweeping such an error under the rug.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   wrapper.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/wrapper.c b/wrapper.c
> index f1c87ec7ea..74aa3b7803 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -434,6 +434,10 @@ static void warn_on_inaccessible(const char *path)
>    * see if the errno indicates a missing file that we can safely ignore.
>    */
>   static int is_missing_file_error(int errno_) {
> +#ifdef GIT_WINDOWS_NATIVE
> +	if (errno_ == EINVAL)
> +		return 1;
> +#endif
>   	return (errno_ == ENOENT || errno_ == ENOTDIR);
>   }

I would prefer to catch the case in the compatibility layer. Here is
a two patch series that would replace your 12/13 and 13/13.

---- 8< ----
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: mingw: verify that paths are not mistaken for remote nicknames

This added test case simply verifies that users will not be bothered
with bogus complaints à la

	warning: unable to access '.git/remotes/D:\repo': Invalid argument

when fetching from a Windows path (in this case, D:\repo).

[j6t: mark the new test as test_expect_failure]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 t/t5580-clone-push-unc.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh
index b195f71ea9..fd719a209e 100755
--- a/t/t5580-clone-push-unc.sh
+++ b/t/t5580-clone-push-unc.sh
@@ -1,13 +1,19 @@
 #!/bin/sh
 
-test_description='various UNC path tests (Windows-only)'
+test_description='various Windows-only path tests'
 . ./test-lib.sh
 
 if ! test_have_prereq MINGW; then
-	skip_all='skipping UNC path tests, requires Windows'
+	skip_all='skipping Windows-only path tests'
 	test_done
 fi
 
+test_expect_failure 'remote nick cannot contain backslashes' '
+	BACKSLASHED="$(pwd | tr / \\\\)" &&
+	git ls-remote "$BACKSLASHED" >out 2>err &&
+	! grep "unable to access" err
+'
+
 UNCPATH="$(pwd)"
 case "$UNCPATH" in
 [A-Z]:*)
-- 
2.13.0.55.g17b7d13330

  reply	other threads:[~2017-05-29 20:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22  6:11 What's cooking in git.git (May 2017, #06; Mon, 22) Junio C Hamano
2017-05-22 17:42 ` Jonathan Nieder
2017-05-23  3:33   ` Junio C Hamano
2017-05-23  5:02     ` Jonathan Nieder
2017-05-23  5:14       ` Junio C Hamano
2017-05-25 12:58 ` Duy Nguyen
2017-05-26  2:56   ` Junio C Hamano
2017-05-26  3:34   ` [PATCH v3 00/13] reporting unexpected errors after (f)open Junio C Hamano
2017-05-26  3:34     ` [PATCH v3 01/13] git_fopen: fix a sparse 'not declared' warning Junio C Hamano
2017-05-26  3:34     ` [PATCH v3 02/13] use xfopen() in more places Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 03/13] clone: use xfopen() instead of fopen() Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 04/13] config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 05/13] config.mak.uname: set FREAD_READS_DIRECTORIES for Darwin, too Junio C Hamano
2017-05-30 18:51       ` Stefan Beller
2017-05-30 23:14         ` Junio C Hamano
2017-05-30 23:32           ` Stefan Beller
2017-05-26  3:35     ` [PATCH v3 06/13] wrapper.c: add and use warn_on_fopen_errors() Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 07/13] wrapper.c: add and use fopen_or_warn() Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 08/13] wrapper.c: make warn_on_inaccessible() static Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 09/13] print errno when reporting a system call error Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 10/13] rerere.c: move error_errno() closer to the source system call Junio C Hamano
2017-05-30 18:58       ` Stefan Beller
2017-05-26  3:35     ` [PATCH v3 11/13] log: fix memory leak in open_next_file() Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 12/13] wrapper: factor out is_missing_file_error() Junio C Hamano
2017-05-30  0:31       ` [PATCH 1/2] compat-util: is_missing_file_error() Junio C Hamano
2017-05-30  0:32         ` [PATCH 2/2] treewide: use is_missing_file_error() where ENOENT and ENOTDIR are checked Junio C Hamano
2017-05-26  3:35     ` [PATCH v3 13/13] is_missing_file_error(): work around EINVAL on Windows Junio C Hamano
2017-05-29 20:25       ` Johannes Sixt [this message]
2017-05-29 20:27         ` [PATCH 2/2] mingw_fopen: report ENOENT for invalid file names Johannes Sixt
2017-05-29 20:40         ` [PATCH 1/2] mingw: verify that paths are not mistaken for remote nicknames Ævar Arnfjörð Bjarmason
2017-05-29 21:02           ` Johannes Sixt
2017-05-29 21:59             ` Ramsay Jones
2017-05-30  0:03               ` Junio C Hamano
2017-05-30 13:40                 ` Ramsay Jones
2017-05-29 23:53             ` Junio C Hamano
2017-05-30  4:46             ` Junio C Hamano
2017-05-30 20:35               ` Johannes Sixt
2017-05-30  0:29         ` Junio C Hamano
2017-05-30 19:13       ` [PATCH v3 13/13] is_missing_file_error(): work around EINVAL on Windows Stefan Beller
2017-05-30 23:17         ` Junio C Hamano
2017-05-30 23:32           ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17b3d445-0cc7-2000-dc67-11fb53c7040b@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).