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

Gitinfo fails on unicode filename #3071

Closed
rac2030 opened this issue Feb 21, 2017 · 5 comments
Closed

Gitinfo fails on unicode filename #3071

rac2030 opened this issue Feb 21, 2017 · 5 comments
Labels

Comments

@rac2030
Copy link

rac2030 commented Feb 21, 2017

Just for fun I added a movie reference, while it works for hugo server run, it fails when I build the output be it locally or on wercker.
I have a File named π.md under content (see http://rac.su and look closer at the footer bar on the right)

Adding it to git works but I noticed git status did list it as "content/\317\200.md"
Hugo fails when building it at
ERROR: 2017/02/21 04:38:02 gitinfo.go:63: Failed to find GitInfo for "content/π.md"

Another example of weird file names is 💩.md which git translates to "content/\360\237\222\251.md" which you can find at http://rac.su/💩 if EnableGitInfo is set to false.

While my case is more fun than anything else, this may also have an effect to other unicode characters like chinese filenames, cyrillic filenames, ... that use unicode.

Searching for unicode in filenames issues, seems like many projects fail on that but there should be some way to enhance hugolib/gitinfo.go to actually handle them correctly.

@bep bep added the Bug label Feb 21, 2017
@bep
Copy link
Member

bep commented Feb 21, 2017

Are you running macOS?

@rac2030
Copy link
Author

rac2030 commented Feb 21, 2017

Yes I'm on OSX 10.10.5 and on wercker it runs on a Debian box.
Hugo itself can handle those files and render them to HTML pages just fine.
I think it's just the way how gitinfo.go normalizes filenames and hands it over to git binary

// Git normalizes file paths on this form:
filename := path.Join(filepath.ToSlash(contentRoot), contentDir, filepath.ToSlash(p.Path()))

@bep bep removed the Bug label Feb 21, 2017
@bep
Copy link
Member

bep commented Feb 21, 2017

The reason I ask about the macOS is the NFD way they store filenames.

So, given a Git repo:

▶ echo "test" >> π.txt                                                                       ◒
▶ git  add -A && git commit
[master (root-commit) a5dd87f] Test
 1 file changed, 1 insertion(+)
 create mode 100644 "\317\200.txt"

So, this is an issue that lives outside of Hugo.

Try:

git config --global core.quotePath false

Alternatively:

git config --global core.precomposeunicode true

@bep bep closed this as completed Feb 21, 2017
@rac2030
Copy link
Author

rac2030 commented Feb 21, 2017

Thanks @bep that was the issue, I searched for a solution on the wrong side.
Setting core.quotePath to false resolves the issue on OSX and on debian as well.
So just for those reading this issue text later, here is my wercker.yml that allows it to build:

box: debian
build:
  steps:
    - install-packages:
        packages: git
    - script:
        name: Set git config core.quotePath to false for emoji filenames
        code: git config --global core.quotePath false
# Build the HUGO page in public folder
    - arjen/hugo-build@1.14.1:
        version: "0.18.1"
        theme: mainroad
        flags: --buildDrafts=false

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants