question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

git.add adds wrong filepath when filepath is multibyte string (like Japanese)

See original GitHub issue

I encountered on Node@10, Chrome 68 and isomorphic-git@0.24.2

  const root = '/my-root'
  const addingFilepath = "日本語"
  await fs.promises.writeFile(path.join(root, addingFilepath), "1")
  await git.add({ fs, dir: root, filepath: addingFilepath })
  await git.commit({
    fs,
    dir: root,
    message: "Add japanese file",
    author: { email: "dummy", name: "dummy" }
  })
  const files = await git.listFiles({ fs, dir: root })
  console.log(files)

This result lost some data

 [ '日' ] // expected:  ['日本語']

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mizchicommented, Jul 30, 2018

@wmhilton

Thank you! It works in this case!

but … sorry, now I found another case under directory.

  const addingFilepath = "docs/日本語"
  await fs.promises.writeFile(path.join(root, addingFilepath), "1")
  await git.add({ fs, dir: root, filepath: addingFilepath })
  await git.commit({
    fs,
    dir: root,
    message: "Add japanese file",
    author: { email: "a", name: "a" }
  })
  const files = await git.listFiles({ fs, dir: root })
  console.log(files) // [ 'docs/日' ]
0reactions
wmhiltoncommented, Jul 30, 2018

Ah yes. It’s not because it was under a directory per se, but due to the length of the filename. Thank you for the fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle Asian characters in file names in Git on OS X
In my limited testing (using Git 1.7.3.2 on Ubuntu), once I disabled core.quotepath , git would display the filenames as expected. Also, even...
Read more >
Problem for creating RTF file for Japanese Language (Origin ...
When I see the 'wrong' RTF file, I find a '}' character in the title string. I think it may cause this problem....
Read more >
gitattributes Documentation - Git
gitattributes file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree...
Read more >
Diff - pub/scm/git/git - Git repositories on kernel
Merge branch 'nd/shallow-deepen' The existing "git fetch --depth=<n>" option was hard to use correctly when making the history of an existing shallow clone ......
Read more >
How to resolve UTF-8 Encoding issue in Jenkins - LinkedIn
To resolve the encoding issue we have to add the environment variable in system as shown below first. These environment variables were added ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found