Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name

2013-06-14 Thread Junio C Hamano
Fredrik Gustafsson  writes:

> On Fri, Jun 14, 2013 at 10:23:52AM -0700, Junio C Hamano wrote:
>> Fredrik Gustafsson  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.
>
> Sorry, I didn't knew enough perl to understand that that was a
> suggestion rather than a hint to a future developer.

Heh, no need to be sorry.  It was a hint, and I just made you a
future developer ;-)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name

2013-06-14 Thread Fredrik Gustafsson
On Fri, Jun 14, 2013 at 10:23:52AM -0700, Junio C Hamano wrote:
> Fredrik Gustafsson  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.

Sorry, I didn't knew enough perl to understand that that was a
suggestion rather than a hint to a future developer.

Now when I see how you meant it's looks like the best solution to me.
To me it looks like we now should be able to handle the multiline case
here. However, git submodule add doesn't handle newline yet, so it
really doesn't matter for now.

Thanks for the help!

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name

2013-06-14 Thread Junio C Hamano
Fredrik Gustafsson  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 
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 
Signed-off-by: Junio C Hamano 
---
 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 () {
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[[PATCH v3] 1/2] [submodule] handle multibyte characters in name

2013-06-14 Thread Fredrik Gustafsson
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 and pathnames that has a double-quote, a
backslash or a control character like a newline or a tab in thme.

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

This patch still does not allow pathnames with characters that do need C-quote,
but the code didn't handle them before, so it is not making things worse. 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".

Solution-suggested-by: Junio C Hamano 
Signed-off-by: Fredrik Gustafsson 
---
 git-submodule.sh   |  2 +-
 t/t7400-submodule-basic.sh | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..bad051e 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 -c core.quotepath=false ls-files --error-unmatch --stage -- 
"$@" ||
echo "unmatched pathspec exists"
) |
perl -e '
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.381.g2ab719e.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html