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

error when there are Chinese files in cloc --diff --git #457

Closed
Zzzzzz0H0 opened this issue Jan 16, 2020 · 4 comments
Closed

error when there are Chinese files in cloc --diff --git #457

Zzzzzz0H0 opened this issue Jan 16, 2020 · 4 comments

Comments

@Zzzzzz0H0
Copy link

hi, I use cloc --git --diff compare 2 committed diffs ,but get a error when changed file name is Chinese

versioin: 1.8.4

os: ubuntu

git add 使用说明.txt

git commit -m "add chinese txt file"

cloc -v  --git --diff HEAD^ HEAD

git ls-tree --name-only -r HEAD
git ls-tree --name-only -r HEAD^
git archive -o /tmp/t4rZiA42Ro.tar HEAD 
'"\344\275\277\347\224\250\350\257\264\346\230\216.txt"' 'test.c'
fatal: pathspec '"\344\275\277\347\224\250\350\257\264\346\230\216.txt"' did not match any files
Failed to create tarfile of files from git. at /var/lib/jenkins/workspace/cloc-1.84/cloc line 4703.

使用说明.txt

@AlDanial
Copy link
Owner

I view this as a git problem, not a cloc problem.

The issue is that the output from git ls-files or git ls-tree cannot be ingested by the git archive command. The filename 使用说明.txt goes in, but when queried, the file name "\344\275\277\347\224\250\350\257\264\346\230\216.txt" comes out--and git claims the repo has no files named "\344\275\277\347\224\250\350\257\264\346\230\216.txt".

Unless you know of a way to revert "\344\275\277\347\224\250\350\257\264\346\230\216.txt" back to 使用说明.txt, there's little for me to do.

@Zzzzzz0H0
Copy link
Author

I see what you mean and i get the answer
https://stackoverflow.com/questions/22827239/how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window

jenkins@Xen11-Build-01:~/workspace/tmp/test$ git config --global core.quotepath off
jenkins@Xen11-Build-01:~/workspace/tmp/test$ git ls-tree HEAD
100644 blob 60442406112bcec13fe37346f25fef867f6dad82	test.c
100644 blob 60442406112bcec13fe37346f25fef867f6dad82	test.java
100644 blob 16d5b0ad9056fc08445b2237b1e302d4daf60669	使用说明.txt

then cloc runs normally and gets the desired result 😄
Thank you again for your help

@AlDanial
Copy link
Owner

I appreciate the research you did on this. I'll add mention the git config --global core.quotepath off in the README.md.

@mmcedora
Copy link

mmcedora commented Mar 6, 2024

Thanks for solving. I also ran into exact same problem with Danish characters.

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

No branches or pull requests

3 participants