{"thread":{"id":"34142","subject":"[[PATCH v3] 0/2] module_list enhancements","startedAt":"2013-06-14T15:56:03Z","lastAt":"2013-06-14T18:33:49Z","messageCount":6,"participants":["Fredrik Gustafsson","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"220880","messageId":"1371225365-4219-1-git-send-email-iveqy@iveqy.com","threadId":"34142","inReplyTo":null,"subject":"[[PATCH v3] 0/2] module_list enhancements","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-14T15:56:03Z","receivedAt":"2013-06-14T15:56:03Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Reworded commit message for\n[submodule] handle multibyte characters in name\nas suggested by Junio.\n\nPrevious iteration can be found here:\nhttp://thread.gmane.org/gmane.comp.version-control.git/227786/\n\nFredrik Gustafsson (2):\n  [submodule] handle multibyte characters in name\n  [submodule] Replace perl-code with sh\n\n git-submodule.sh           | 53 ++++++++++++++++++++--------------------------\n t/t7400-submodule-basic.sh | 12 +++++++++++\n 2 files changed, 35 insertions(+), 30 deletions(-)\n\n-- \n1.8.3.1.381.g2ab719e.dirty\n"},{"id":"220881","messageId":"1371225365-4219-2-git-send-email-iveqy@iveqy.com","threadId":"34142","inReplyTo":"1371225365-4219-1-git-send-email-iveqy@iveqy.com","subject":"[[PATCH v3] 1/2] [submodule] handle multibyte characters in name","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-14T15:56:04Z","receivedAt":"2013-06-14T15:56:04Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Many \"git submodule\" operations do not work on a submodule at a path whose\nname is not in ASCII.\n\nThis is because \"git ls-files\" is used to find which paths are bound to\nsubmodules to the current working tree, and the output is C-quoted by default\nfor non ASCII pathnames and pathnames that has a double-quote, a\nbackslash or a control character like a newline or a tab in thme.\n\nTell \"git ls-files\" to not C-quote its output, which is easier than unwrapping\nC-quote ourselves.\n\nThis patch still does not allow pathnames with characters that do need C-quote,\nbut the code didn't handle them before, so it is not making things worse. The\ncorrect approach to solve the problem for all pathnames may be to use\n\"ls-files -z\" and tell the Perl script that reads its output to read NUL\nseparated records by using $/ = \"\\0\".\n\nSolution-suggested-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Fredrik Gustafsson <iveqy@iveqy.com>\n---\n git-submodule.sh           |  2 +-\n t/t7400-submodule-basic.sh | 12 ++++++++++++\n 2 files changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 79bfaac..bad051e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -113,7 +113,7 @@ resolve_relative_url ()\n module_list()\n {\n \t(\n-\t\tgit ls-files --error-unmatch --stage -- \"$@\" ||\n+\t\tgit -c core.quotepath=false ls-files --error-unmatch --stage -- \"$@\" ||\n \t\techo \"unmatched pathspec exists\"\n \t) |\n \tperl -e '\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex ff26535..d5743ee 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -868,4 +868,16 @@ test_expect_success 'submodule deinit fails when submodule has a .git directory\n \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\"\n '\n \n+test_expect_success 'submodule with strange name works \"å äö\"' '\n+\tmkdir \"å äö\" &&\n+\t(\n+\t\tcd \"å äö\" &&\n+\t\tgit init &&\n+\t\ttouch sub\n+\t\tgit add sub\n+\t\tgit commit -m \"init sub\"\n+\t)\n+\tgit submodule add \"/å äö\" &&\n+\ttest -n \"$(git submodule | grep \"å äö\")\"\n+'\n test_done\n-- \n1.8.3.1.381.g2ab719e.dirty\n"},{"id":"220882","messageId":"1371225365-4219-3-git-send-email-iveqy@iveqy.com","threadId":"34142","inReplyTo":"1371225365-4219-1-git-send-email-iveqy@iveqy.com","subject":"[[PATCH v3] 2/2] [submodule] Replace perl-code with sh","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-14T15:56:05Z","receivedAt":"2013-06-14T15:56:05Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"This will prevent a fork and makes the code similair to the rest of the\nfile.\n\nIn the long term git-submodule.sh needs to use something else than sh to\nhandle newline in filenames (and therefore needs to use a language that\naccepts \\0 in strings). However I don't think that keeping that small\nperl-part will ease any rewrite.\n\nSigned-off-by: Fredrik Gustafsson <iveqy@iveqy.com>\n---\n git-submodule.sh | 51 ++++++++++++++++++++++-----------------------------\n 1 file changed, 22 insertions(+), 29 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bad051e..be96934 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -112,38 +112,31 @@ resolve_relative_url ()\n #\n module_list()\n {\n+\tnull_sha1=0000000000000000000000000000000000000000\n+\tunmerged=\n \t(\n \t\tgit -c core.quotepath=false ls-files --error-unmatch --stage -- \"$@\" ||\n-\t\techo \"unmatched pathspec exists\"\n+\t\techo \"#unmatched\"\n \t) |\n-\tperl -e '\n-\tmy %unmerged = ();\n-\tmy ($null_sha1) = (\"0\" x 40);\n-\tmy @out = ();\n-\tmy $unmatched = 0;\n-\twhile (<STDIN>) {\n-\t\tif (/^unmatched pathspec/) {\n-\t\t\t$unmatched = 1;\n-\t\t\tnext;\n-\t\t}\n-\t\tchomp;\n-\t\tmy ($mode, $sha1, $stage, $path) =\n-\t\t\t/^([0-7]+) ([0-9a-f]{40}) ([0-3])\\t(.*)$/;\n-\t\tnext unless $mode eq \"160000\";\n-\t\tif ($stage ne \"0\") {\n-\t\t\tif (!$unmerged{$path}++) {\n-\t\t\t\tpush @out, \"$mode $null_sha1 U\\t$path\\n\";\n-\t\t\t}\n-\t\t\tnext;\n-\t\t}\n-\t\tpush @out, \"$_\\n\";\n-\t}\n-\tif ($unmatched) {\n-\t\tprint \"#unmatched\\n\";\n-\t} else {\n-\t\tprint for (@out);\n-\t}\n-\t'\n+\twhile read mode sha1 stage path\n+\tdo\n+\t\tif test $mode = \"#unmatched\"\n+\t\tthen\n+\t\t\techo \"#unmatched\"\n+\t\telif test $mode = \"160000\"\n+\t\tthen\n+\t\t\tif test $stage != \"0\"\n+\t\t\tthen\n+\t\t\t\tif test \"$unmerged\" != \"$path\"\n+\t\t\t\tthen\n+\t\t\t\t\techo \"$mode $null_sha1 U $path\"\n+\t\t\t\tfi\n+\t\t\t\tunmerged=\"$path\"\n+\t\t\telse\n+\t\t\t\techo \"$mode $sha1 $stage $path\"\n+\t\t\tfi\n+\t\tfi\n+\tdone\n }\n \n die_if_unmatched ()\n-- \n1.8.3.1.381.g2ab719e.dirty\n"},{"id":"220894","messageId":"7va9msppw7.fsf@alter.siamese.dyndns.org","threadId":"34142","inReplyTo":"1371225365-4219-2-git-send-email-iveqy@iveqy.com","subject":"Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-14T17:23:52Z","receivedAt":"2013-06-14T17:23:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fredrik Gustafsson <iveqy@iveqy.com> writes:\n\n> ... The\n> correct approach to solve the problem for all pathnames may be to use\n> \"ls-files -z\" and tell the Perl script that reads its output to read NUL\n> separated records by using $/ = \"\\0\".\n\nI've tentatively queued the attached without 2/2; the scriptlet is\nsmall enough not to matter in an eventual rewrite, so it shouldn't\nmake a difference either way.\n\n-- >8 --\nFrom: Fredrik Gustafsson <iveqy@iveqy.com>\nSubject: [PATCH] handle multibyte characters in name\n\nMany \"git submodule\" operations do not work on a submodule at a path whose\nname is not in ASCII.\n\nThis is because \"git ls-files\" is used to find which paths are bound to\nsubmodules to the current working tree, and the output is C-quoted by default\nfor non ASCII pathnames.\n\nTell \"git ls-files\" to not C-quote its output, which is easier than unwrapping\nC-quote ourselves.\n\nSigned-off-by: Fredrik Gustafsson <iveqy@iveqy.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-submodule.sh           |  3 ++-\n t/t7400-submodule-basic.sh | 12 ++++++++++++\n 2 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 79bfaac..48bdf84 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -113,7 +113,7 @@ resolve_relative_url ()\n module_list()\n {\n \t(\n-\t\tgit ls-files --error-unmatch --stage -- \"$@\" ||\n+\t\tgit ls-files -z --error-unmatch --stage -- \"$@\" ||\n \t\techo \"unmatched pathspec exists\"\n \t) |\n \tperl -e '\n@@ -121,6 +121,7 @@ module_list()\n \tmy ($null_sha1) = (\"0\" x 40);\n \tmy @out = ();\n \tmy $unmatched = 0;\n+\t$/ = \"\\0\";\n \twhile (<STDIN>) {\n \t\tif (/^unmatched pathspec/) {\n \t\t\t$unmatched = 1;\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex ff26535..d5743ee 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -868,4 +868,16 @@ test_expect_success 'submodule deinit fails when submodule has a .git directory\n \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\"\n '\n \n+test_expect_success 'submodule with strange name works \"å äö\"' '\n+\tmkdir \"å äö\" &&\n+\t(\n+\t\tcd \"å äö\" &&\n+\t\tgit init &&\n+\t\ttouch sub\n+\t\tgit add sub\n+\t\tgit commit -m \"init sub\"\n+\t)\n+\tgit submodule add \"/å äö\" &&\n+\ttest -n \"$(git submodule | grep \"å äö\")\"\n+'\n test_done\n-- \n1.8.3.1-538-gb4d04a7\n"},{"id":"220901","messageId":"20130614182741.GA5812@paksenarrion.iveqy.com","threadId":"34142","inReplyTo":"7va9msppw7.fsf@alter.siamese.dyndns.org","subject":"Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-14T18:27:41Z","receivedAt":"2013-06-14T18:27:41Z","isPatch":true,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Fri, Jun 14, 2013 at 10:23:52AM -0700, Junio C Hamano wrote:\n> Fredrik Gustafsson <iveqy@iveqy.com> writes:\n> \n> > ... The\n> > correct approach to solve the problem for all pathnames may be to use\n> > \"ls-files -z\" and tell the Perl script that reads its output to read NUL\n> > separated records by using $/ = \"\\0\".\n> \n> I've tentatively queued the attached without 2/2; the scriptlet is\n> small enough not to matter in an eventual rewrite, so it shouldn't\n> make a difference either way.\n\nSorry, I didn't knew enough perl to understand that that was a\nsuggestion rather than a hint to a future developer.\n\nNow when I see how you meant it's looks like the best solution to me.\nTo me it looks like we now should be able to handle the multiline case\nhere. However, git submodule add doesn't handle newline yet, so it\nreally doesn't matter for now.\n\nThanks for the help!\n\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"220903","messageId":"7vfvwko836.fsf@alter.siamese.dyndns.org","threadId":"34142","inReplyTo":"20130614182741.GA5812@paksenarrion.iveqy.com","subject":"Re: [[PATCH v3] 1/2] [submodule] handle multibyte characters in name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-14T18:33:49Z","receivedAt":"2013-06-14T18:33:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fredrik Gustafsson <iveqy@iveqy.com> writes:\n\n> On Fri, Jun 14, 2013 at 10:23:52AM -0700, Junio C Hamano wrote:\n>> Fredrik Gustafsson <iveqy@iveqy.com> writes:\n>> \n>> > ... The\n>> > correct approach to solve the problem for all pathnames may be to use\n>> > \"ls-files -z\" and tell the Perl script that reads its output to read NUL\n>> > separated records by using $/ = \"\\0\".\n>> \n>> I've tentatively queued the attached without 2/2; the scriptlet is\n>> small enough not to matter in an eventual rewrite, so it shouldn't\n>> make a difference either way.\n>\n> Sorry, I didn't knew enough perl to understand that that was a\n> suggestion rather than a hint to a future developer.\n\nHeh, no need to be sorry.  It was a hint, and I just made you a\nfuture developer ;-)\n"}]}