git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fredrik Gustafsson <iveqy@iveqy.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Ilya Kulakov <kulakov.ilya@gmail.com>, git@vger.kernel.org
Subject: Re: Bug: `gitsubmodule` does not list modules with unicode characters
Date: Sat, 8 Jun 2013 03:05:56 +0200	[thread overview]
Message-ID: <20130608010556.GA28819@paksenarrion.iveqy.com> (raw)
In-Reply-To: <51500B34.30801@web.de>

On Mon, Mar 25, 2013 at 09:30:44AM +0100, Jens Lehmann wrote:
> Am 23.03.2013 17:28, schrieb Ilya Kulakov:
> > The `git submodule` commands seem to ignore modules which paths contain
> > unicode characters.
> > 
> > Consider the following steps to reproduce the problem:
> > 
> >   1. Create a directory with name that contains at least one unicode character
> >      (e.g. "ûñïçödé-rèpø")
> > 
> >   2. Initialize git repository within this directory
> > 
> >   3. Add this repository as a submodule to another repository so that
> >      unicode characters will appear in the path to the module
> >      (e.g. "../ûñïçödé-rèpø")
> > 
> >   4. Check that .gitmodules file is updated and contains record
> >      about just added module
> > 
> >   5. List submodules with using `git submodule` and find out
> >      that just added module is not listed
> 
> Thanks for your report. It is known that git submodule does not behave
> very well when path names contain special characters. I'll look into
> that when I find some time to see if we can easily fix your problem.

I've looked into this a bit.

git ls-files will return all filenames "c-style quoted". Hence the
filename åäö will be returned as "303245303244303266". This is of course
also wrong as it should be "\303\245\303\244\303\266".

However, if we tell git ls-files to use \0 instead of \n for line
termination. We get åäö returned. So how can the choose of line termination
effect the encoding?

Look in quote.c. The following patch will solve this particular problem
(but break other usecases!)

diff --git a/quote.c b/quote.c
index 911229f..2870ca5 100644
--- a/quote.c
+++ b/quote.c
@@ -284,7 +284,7 @@ void quote_two_c_style(struct strbuf *sb, const char *prefix, const char *path,
 void write_name_quoted(const char *name, FILE *fp, int terminator)
 {
 	if (terminator) {
-		quote_c_style(name, NULL, fp, 0);
+		fputs(name, fp);
 	} else {
 		fputs(name, fp);
 	}

Why don't we always print names quoted? IMHO the choose of line
termination should not do anything else than alter the line termination.

However, an other solution would be to use git ls-files -z in
git-submodule.sh and then rewrite the perl-code to handle \0 instead
of \n.

(The same perl-code I wanted to throw away 13 months ago but
Junio wanted to keep because perl can handle \0 and eventually -z should
be used according to him. He was right.)

However, a shortcut would be to the patch below. It will work as long as
there's no newline in the filename (is that really something we want to
support? If not, let's throw away perl and stick with the sed solution
below).

diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..31524d3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -113,9 +113,10 @@ resolve_relative_url ()
 module_list()
 {
 	(
-		git ls-files --error-unmatch --stage -- "$@" ||
+		git ls-files --error-unmatch --stage -z -- "$@" ||
 		echo "unmatched pathspec exists"
 	) |
+	sed -e 's/\x00/\n/g' |
 	perl -e '
 	my %unmerged = ();
 	my ($null_sha1) = ("0" x 40);

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iveqy@iveqy.com

  reply	other threads:[~2013-06-08  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-23 16:28 Bug: `gitsubmodule` does not list modules with unicode characters Ilya Kulakov
2013-03-25  8:30 ` Jens Lehmann
2013-06-08  1:05   ` Fredrik Gustafsson [this message]
2013-06-08  9:18     ` Jonathan Nieder
2013-06-08 12:06       ` 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

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

  git send-email \
    --in-reply-to=20130608010556.GA28819@paksenarrion.iveqy.com \
    --to=iveqy@iveqy.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=kulakov.ilya@gmail.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.
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 NNTP newsgroup(s).