Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access remote repository if the URL contains Chinese word #945

Closed
YueLinHo opened this issue Nov 6, 2016 · 20 comments
Closed

Can't access remote repository if the URL contains Chinese word #945

YueLinHo opened this issue Nov 6, 2016 · 20 comments
Assignees
Labels
Milestone

Comments

@YueLinHo
Copy link

YueLinHo commented Nov 6, 2016

  • [v] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?

64 bit

$ git --version --build-options
git version 2.10.2.windows.1
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [版本 6.1.7601]

Win7 64 Pro

  • What options did you set as part of the installation? Or did you choose the defaults?
> type "C:\Program Files\Git\etc\install-options.txt"
Path Option: Cmd
SSH Option: OpenSSH
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related to the issue you're seeing?

Suppose 2.10.1 has the same issue.

Study some, and compare the changes between 2.10.0 and 2.10.1, then I guess the changes of url.c in
commit introduce hex2chr() for converting two hexadecimal digits to a character may be the key?

Also see TortoiseGit issue 2859

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

Can't clone if URL contains Chinese word(s)

$ git.exe clone --progress -v "D:\Temp\i2859\Test中文.git" "D:\Temp\i2859\Test中文2.10.2"

Or add a remote and its URL contains Chinese word(s). Then can't perform fetch/push anymore.

Note: English URL works fine.

  • What did you expect to occur after running these commands?

Like Git Bash does:

$ git.exe clone --progress -v "D:\Temp\i2859\Test中文.git" "D:\Temp\i2859\Test中文2.10.2"
Cloning into 'D:\Temp\i2859\Test中文2.10.2'...
done.
  • What actually happened instead?
D:\Temp\i2589>git.exe clone --progress -v "D:\Temp\i2589\Test中文.git" "D:\Temp\i2589\Test中文2.10.2"
Cloning into 'D:\Temp\i2589\Test中文2.10.2'...
"git-upload-pack 'D:\Temp\i2589\Test中�.git'": git-upload-pack 'D:\Temp\i2589\Test中�.git': No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Warning: Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Consolas!

default

Update 1

TortoiseGit interface shows those two strings normally:

image

And test with true type in cmd.exe:

D:\Temp\i2589>git clone "D:\Temp\i2859\Test中文.git" "D:\Temp\i2859\中文2.10.2"
Cloning into 'D:\Temp\i2859\中文2.10.2'...
"git-upload-pack 'D:\Temp\i2859\Test中�.git'": git-upload-pack 'D:\Temp\i2859
\Test中�.git': No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

image

That warning is gone.

Update 2

Other testing results: (TortoiseGit calls git.exe)

tests

As you can see:

  1. 2.10.0 is last good for TortoiseGit
  2. 2.10.1 is first bad. Bash works fine, but CMD. (based on that TortoiseGit calls git.exe, and the result in my last comment)

Workaround

call set LC_ALL=C in cmd.exe

@PhilipOakley
Copy link

----- Original Message -----
From: Yue Lin Ho
To: git-for-windows/git
Sent: Sunday, November 06, 2016 4:08 PM
Subject: [git-for-windows/git] Can't access remote repository if the URL contains Chinese word (#945)

a.. [v] I was not able to find an open or closed issue matching what I'm seeing 

Setup
a.. Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.10.2.windows.1
a.. Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [版本 6.1.7601]
a.. What options did you set as part of the installation? Or did you choose the
defaults?

One of the following:

type "C:\Program Files\Git\etc\install-options.txt"
type "C:\Program Files (x86)\Git\etc\install-options.txt"
type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Path Option: Cmd
SSH Option: OpenSSH
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
a.. Any other interesting things about your environment that might be related
to the issue you're seeing?
Suppose 2.10.1 has the same issue.

Study some, and compare the changes between 2.10.0 and 2.10.1, then I guess the changes of url.c in
commit introduce hex2chr() for converting two hexadecimal digits to a character may be the key?

Also see TortoiseGit issue 2859

Details
a.. Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
CMD

a.. What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue. 

Add a remote and its URL contains Chinese word(s). Then can't perform clone/fetch/push anymore.

Note: English URL works fine.

a.. What did you expect to occur after running these commands? 

Like Git Bash does:

$ git.exe clone --progress -v "D:\Temp\i2859\Test中文.git" "D:\Temp\i2859\Test中文2.10.2"
Cloning into 'D:\Temp\i2859\Test中文2.10.2'...
done.
a.. What actually happened instead?
D:\Temp\i2589>git.exe clone --progress -v "D:\Temp\i2589\Test中文.git" "D:\Temp\i2589\Test中文2.10.2"
Cloning into 'D:\Temp\i2589\Test中文2.10.2'...
"git-upload-pack 'D:\Temp\i2589\Test中�.git'": git-upload-pack 'D:\Temp\i2589\Test中�.git': No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Warning: Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Consolas!

hello,

I think this warning message "Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Consolas!" Is at the heart of the problem.

It looks like an encoding problem. Git assumes you use UTF-8 unicode. I guess that is not how your chinese characters/words are being encoded when passed to git, so while they are displayed correctly on screen, they are different 8-bit byte sequences.

Try the suggestion of "switching to a TrueType font such as Consolas" and seeing if that has an effect.

Philip

@YueLinHo
Copy link
Author

YueLinHo commented Nov 7, 2016

@PhilipOakley

Hi,

I test it again with true type:

D:\Temp\i2589>git clone "D:\Temp\i2859\Test中文.git" "D:\Temp\i2859\中文2.10.2"
Cloning into 'D:\Temp\i2859\中文2.10.2'...
"git-upload-pack 'D:\Temp\i2859\Test中�.git'": git-upload-pack 'D:\Temp\i2859
\Test中�.git': No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

image

That warning is gone.

Note: Git Bash works fine, but Windows Command Prompt.

@YueLinHo
Copy link
Author

YueLinHo commented Nov 7, 2016

Post earlier testing results: (TortoiseGit calls git.exe)

tests

As you can see:

  1. 2.10.0 is last good for TortoiseGit
  2. 2.10.1 is first bad. Bash works fine, but CMD. (based on that TortoiseGit calls git.exe, and the result in my last comment)

So, I compared the code between tag v2.10.0.windows.1 (commit 1f448f5) and v2.10.1.windows.1 (commit 3374789), and my first guessing is the changes of url.c in commit introduce hex2chr() for converting two hexadecimal digits to a character. But, I am not sure it is the root cause.

@dscho
Copy link
Member

dscho commented Nov 7, 2016

Please call set LC_ALL=C in cmd.exe and try to clone again.

@dscho dscho added the bug label Nov 7, 2016
@YueLinHo
Copy link
Author

YueLinHo commented Nov 7, 2016

@dscho OH~ YES~ set LC_ALL=C works. (Oh~ Happy~~ ^____^)

Thank you!!!!!

@PhilipOakley
Copy link

Hi,

I still suspect that it's an encoding issue.

Your results show that this is not a problem for GfW 2.10.1/2 from git bash, so we are doing something right.

The results then show that when TortoiseGit does the command then it fails. So it will be somewhere in the tortoiseGit interface. (with the same suspect that it is a 'bad' code page / encoding issue).

Can you capture the two strings as byte sequences to see if they follow the UTF-8 and code page encodings?

P.
----- Original Message -----
From: Yue Lin Ho
To: git-for-windows/git
Cc: Philip Oakley ; Mention
Sent: Monday, November 07, 2016 9:35 AM
Subject: Re: [git-for-windows/git] Can't access remote repository if the URL contains Chinese word (#945)

Post earlier testing result: (TortoiseGit calls git.exe)

As you can see:

  1. 2.10.0 is last good for TortoiseGit

  2. Bash works fine, but CMD (based on that TortoiseGit calls git.exe, and the result in my last comment).

    So, I compared the code between tag v2.10.0.windows.1 (commit 1f448f5) and v2.10.1.windows.1 (commit 3374789), and my first guessing is the changes of url.c in commit introduce hex2chr() for converting two hexadecimal digits to a character. But, I am not sure it is the root cause.


    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub, or mute the thread.

@YueLinHo
Copy link
Author

YueLinHo commented Nov 7, 2016

@PhilipOakley

I still suspect that it's an encoding issue.
Your results show that this is not a problem for GfW 2.10.1/2 from git bash, so we are doing something right.
The results then show that when TortoiseGit does the command then it fails. So it will be somewhere in the tortoiseGit interface. (with the same suspect that it is a 'bad' code page / encoding issue).

Can you capture the two strings as byte sequences to see if they follow the UTF-8 and code page encodings?

TortoiseGit interface shows those two strings normally:

image

So, I guess it follows. :-)

@YueLinHo
Copy link
Author

YueLinHo commented Nov 9, 2016

I can build Git for Windows and its installer now. Then, I tested the installer which revert the change by the commit I suspected, say commit d233097. The result is that clone still does not work. So, I think that that commit can be excluded. :-)

@YueLinHo
Copy link
Author

YueLinHo commented Nov 9, 2016

I know Git for Windows can be built with VS2015 since 2.10.2. So, my next step may be debug it with VS2015? right?

@YueLinHo
Copy link
Author

YueLinHo commented Nov 10, 2016

I built 2.10.0 and made a installer, then can't clone. XD

Looks like it's not source code problem. Any idea?

@PhilipOakley
Copy link

I build 2.10.0 and make a installer, then can't clone. XD
Looks like it's not source code problem. Any idea?

It maybe that your build completed, and overwrote your current install (within the sdk), and that there is some issue with your build.

Does your regular Git still work.

@dscho
Copy link
Member

dscho commented Nov 16, 2016

@YueLinHo is there a chance to teach TortoiseGit to set LC_ALL=C? Or would it help if Git for Windows' cmd\git.exe would set LC_ALL unless it was set already?

@YueLinHo
Copy link
Author

@dscho

is there a chance to teach TortoiseGit to set LC_ALL=C?

I am not sure. I guess TortoiseGit can do so. I will find time to try it. (@csware Can TortoiseGit do it?)
For me, I added a env. var. LC_ALL=C, so that I can use TortoiseGit in daily work.

Or would it help if Git for Windows' cmd\git.exe would set LC_ALL unless it was set already?

I think it would help. ^_^

@csware
Copy link

csware commented Nov 17, 2016

TortoiseGit could set LC_ALL=C, however, then all localization is disabled, right?

@YueLinHo
Copy link
Author

TortoiseGit could set LC_ALL=C, however, then all localization is disabled, right?

Right. So, you remind me that I want to know why my GfW 2.10.0 installer does not work out.
Are there other changes beside source code changes? package changed?

dscho added a commit to git-for-windows/build-extra that referenced this issue Nov 17, 2016
The regression where Git would not interpret non-ASCII
characters passed from a CMD window correctly [has been
fixed](git-for-windows/git#945).

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho self-assigned this Nov 17, 2016
@dscho dscho added this to the v2.11.0 milestone Nov 17, 2016
@dscho
Copy link
Member

dscho commented Nov 18, 2016

TortoiseGit could set LC_ALL=C, however, then all localization is disabled, right?

@csware obviously I meant "unless LC_ALL was already defined".

@dscho
Copy link
Member

dscho commented Nov 18, 2016

I want to know why my GfW 2.10.0 installer does not work out.

@YueLinHo Would you kindly open a new ticket with a concise description what you tried and what you expected and what you got instead?

@YueLinHo
Copy link
Author

Would you kindly open a new ticket with a concise description what you tried and what you expected and what you got instead?

Sure. See #965. ^_^

@YueLinHo
Copy link
Author

YueLinHo commented Jan 23, 2017

Found there is a similar issue, say #1036, So I remove my system env, var. LC_ALL=C and re-test some for 2.11.0.windows.3:

Screenshot

image

Result

Looks like the issue is not fixed.

CLI - One of the Error Message

D:\Temp\gfwi1036\test2>git version
git version 2.11.0.windows.3

D:\Temp\gfwi1036\test2>git remote -v
local_one       D:/Temp/gfwi1036/測試 (fetch)
local_one       D:/Temp/gfwi1036/測試 (push)
origin  D:\Temp\gfwi1036\測試 (fetch)
origin  D:\Temp\gfwi1036\測試 (push)
share_on_server //192.168.x.xxx/_bk2/測試 (fetch)
share_on_server //192.168.x.xxx/_bk2/測試 (push)

D:\Temp\gfwi1036\test2>git fetch origin -v
"git-upload-pack 'D:\Temp\gfwi1036\測試'": git-upload-pack 'D:\Temp\gfwi1036\測
試': No such file or directory
fatal: Could not read from remote repository.

Git Gui - One of the Error Message

"git-upload-pack 'D:\Temp\gfwi1036\測試'": git-upload-pack 'D:\Temp\gfwi1036\測試': No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

TortoiseGit

TortoiseGit 2.3.4+ has the same fix, and it works for me. Here is the testing of 2.3.8:

git.exe fetch -v --progress "origin"

From D:\Temp\gfwi1036\測試
= [up to date]      master     -> origin/master

image


After adding that system env. var. back, everything works.

@YueLinHo
Copy link
Author

Suppose this issue is not just for Chinese words, but also for non-ASCII characters.
(Just adding a comment which making this issue to be found easily.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants