git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Fredrik Gustafsson <iveqy@iveqy.com>
Cc: git@vger.kernel.org, jens.lehmann@web.de
Subject: Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name
Date: Fri, 14 Jun 2013 10:23:52 -0700	[thread overview]
Message-ID: <7va9msppw7.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1371225365-4219-2-git-send-email-iveqy@iveqy.com> (Fredrik Gustafsson's message of "Fri, 14 Jun 2013 17:56:04 +0200")

Fredrik Gustafsson <iveqy@iveqy.com> writes:

> ... The
> correct approach to solve the problem for all pathnames may be to use
> "ls-files -z" and tell the Perl script that reads its output to read NUL
> separated records by using $/ = "\0".

I've tentatively queued the attached without 2/2; the scriptlet is
small enough not to matter in an eventual rewrite, so it shouldn't
make a difference either way.

-- >8 --
From: Fredrik Gustafsson <iveqy@iveqy.com>
Subject: [PATCH] handle multibyte characters in name

Many "git submodule" operations do not work on a submodule at a path whose
name is not in ASCII.

This is because "git ls-files" is used to find which paths are bound to
submodules to the current working tree, and the output is C-quoted by default
for non ASCII pathnames.

Tell "git ls-files" to not C-quote its output, which is easier than unwrapping
C-quote ourselves.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-submodule.sh           |  3 ++-
 t/t7400-submodule-basic.sh | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..48bdf84 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -113,7 +113,7 @@ resolve_relative_url ()
 module_list()
 {
 	(
-		git ls-files --error-unmatch --stage -- "$@" ||
+		git ls-files -z --error-unmatch --stage -- "$@" ||
 		echo "unmatched pathspec exists"
 	) |
 	perl -e '
@@ -121,6 +121,7 @@ module_list()
 	my ($null_sha1) = ("0" x 40);
 	my @out = ();
 	my $unmatched = 0;
+	$/ = "\0";
 	while (<STDIN>) {
 		if (/^unmatched pathspec/) {
 			$unmatched = 1;
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index ff26535..d5743ee 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -868,4 +868,16 @@ test_expect_success 'submodule deinit fails when submodule has a .git directory
 	test -n "$(git config --get-regexp "submodule\.example\.")"
 '
 
+test_expect_success 'submodule with strange name works "å äö"' '
+	mkdir "å äö" &&
+	(
+		cd "å äö" &&
+		git init &&
+		touch sub
+		git add sub
+		git commit -m "init sub"
+	)
+	git submodule add "/å äö" &&
+	test -n "$(git submodule | grep "å äö")"
+'
 test_done
-- 
1.8.3.1-538-gb4d04a7

  reply	other threads:[~2013-06-14 17:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14 15:56 [[PATCH v3] 0/2] module_list enhancements Fredrik Gustafsson
2013-06-14 15:56 ` [[PATCH v3] 1/2] [submodule] handle multibyte characters in name Fredrik Gustafsson
2013-06-14 17:23   ` Junio C Hamano [this message]
2013-06-14 18:27     ` Fredrik Gustafsson
2013-06-14 18:33       ` Junio C Hamano
2013-06-14 15:56 ` [[PATCH v3] 2/2] [submodule] Replace perl-code with sh Fredrik Gustafsson

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=7va9msppw7.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=iveqy@iveqy.com \
    --cc=jens.lehmann@web.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).