git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Brandon Williams <bmwill@google.com>,
	Joachim Durchholz <jo@durchholz.org>,
	Stefan Beller <sbeller@google.com>
Subject: Re: [PATCH 2/2] test-lib: exhaustively insert non-alnum ASCII into the TRASH_DIRECTORY name
Date: Mon, 10 Apr 2017 21:14:54 -0400	[thread overview]
Message-ID: <20170411011454.oteysryg4t44gebj@sigill.intra.peff.net> (raw)
In-Reply-To: <CACBZZX7OfM-zivJAQMXdNarHDjAhzQhqGNZNs2QqDUyOo3AA0g@mail.gmail.com>

On Tue, Apr 11, 2017 at 01:23:32AM +0200, Ævar Arnfjörð Bjarmason wrote:

> * Most of the tests fail because git clone can't deal with cloning a
> repo with a \r in the path. The error we produce when we try is quite
> bad and doesn't indicate what went wrong:
> 
> $ rm -rf /tmp/git.*; mkdir /tmp/git.$(perl -e 'print chr 13') && cd
> /tmp/git.* && git init --bare b && file b && git clone b c
> /b/tialized empty Git repository in /tmp/git.
> b: directory
> Cloning into 'c'...
> fatal: '/tmp/git. /b' does not appear to be a git repository
> fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights
> and the repository exists.
> 
> So file(1) shows it exists, a strace shows that git knows it exists at
> some point, but something gets lost along the way.

It's the round-trip through the config. It writes:

  [remote "origin"]
  url = /tmp/git.^M/b

into the config (where ^M is a literal CR). And then on reading it back,
unquoted whitespace in config values is converted to spaces, which is
why you see "git. /b" in the error message (the other ones are ugly
because it's writing the raw CR in via printf, and your terminal
respects it. Try "2>&1 | cat -A" when debugging this sort of thing (our
error and warning messages clean up cruft like this already, but
informational messages don't always go through vreportf()).

Anyway, something like this would fix it (it actually adds "\r" to the
config format, which is how we handle \n and \t; we could do it without
touching the parsing side if we taught store_write_pair() to recognize
that \r needs to go in double-quotes).

diff --git a/config.c b/config.c
index 1a4d85537..4a36a37ba 100644
--- a/config.c
+++ b/config.c
@@ -526,6 +526,9 @@ static char *parse_value(void)
 			case 'n':
 				c = '\n';
 				break;
+			case 'r':
+				c = '\r';
+				break;
 			/* Some characters escape as themselves */
 			case '\\': case '"':
 				break;
@@ -2172,6 +2175,9 @@ static int store_write_pair(int fd, const char *key, const char *value)
 		case '\t':
 			strbuf_addstr(&sb, "\\t");
 			break;
+		case '\r':
+			strbuf_addstr(&sb, "\\r");
+			break;
 		case '"':
 		case '\\':
 			strbuf_addch(&sb, '\\');

-Peff

  parent reply	other threads:[~2017-04-11  1:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-09 19:11 [PATCH 0/2] test: Detect *lots* of bugs by adding non-alnum to trash dir names Ævar Arnfjörð Bjarmason
2017-04-09 19:11 ` [PATCH 1/2] tests: mark tests that fail when the TEST_DIRECTORY is unusual Ævar Arnfjörð Bjarmason
2017-04-09 19:11 ` [PATCH 2/2] test-lib: exhaustively insert non-alnum ASCII into the TRASH_DIRECTORY name Ævar Arnfjörð Bjarmason
2017-04-10  1:47   ` SZEDER Gábor
2017-04-10  8:02     ` Ævar Arnfjörð Bjarmason
2017-04-10 11:19       ` SZEDER Gábor
2017-04-10 11:40         ` Ævar Arnfjörð Bjarmason
2017-04-10 13:38           ` Jeff King
2017-04-10 14:59             ` Joachim Durchholz
2017-04-10 16:57               ` Jeff King
2017-04-10 18:19                 ` Joachim Durchholz
2017-04-10 19:22                   ` Jeff King
2017-04-10 13:43           ` SZEDER Gábor
2017-04-10 23:23   ` Ævar Arnfjörð Bjarmason
2017-04-11  0:30     ` [PATCH] connect.c: handle errors from split_cmdline Jeff King
2017-04-11  0:35       ` Jeff King
2017-04-11  9:27         ` Ævar Arnfjörð Bjarmason
2017-04-11 10:54           ` Jeff King
2017-04-11 11:06             ` Ævar Arnfjörð Bjarmason
2017-04-17  0:51               ` Junio C Hamano
2017-04-17  0:54               ` Junio C Hamano
2017-04-19 10:59                 ` Ævar Arnfjörð Bjarmason
2017-04-11  1:14     ` Jeff King [this message]
2017-04-11  6:28     ` [PATCH 2/2] test-lib: exhaustively insert non-alnum ASCII into the TRASH_DIRECTORY name Joachim Durchholz
2017-04-09 20:37 ` [PATCH 0/2] test: Detect *lots* of bugs by adding non-alnum to trash dir names Joachim Durchholz

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=20170411011454.oteysryg4t44gebj@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jo@durchholz.org \
    --cc=sbeller@google.com \
    /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).