14

I have a repository that has windows (cp1252) and linux (utf8) committers. Obviously Git gets confused, and puts invalid (from linux's perspective) filenames. I know I can use hooks to rename the files in one side (on linux's side, for instance, renaming the files from cp1252 to utf8 when they come and the reverse when they go), but ... exactly how do I do that? Exactly which hooks I have to write?

1
  • 1
    Wouldn't it be easier to convert the files once and use UTF-8 on Windows as well?
    – TimWolla
    Jun 20, 2013 at 12:24

1 Answer 1

7

Good question!

http://www.serverwatch.com/tutorials/article.php/3705216 Talks about a tool called "convmv" which will fix filenames. This might be helpful.

Iconv http://www.gnu.org/software/libiconv/ can convert arbitrary text into different character sets.

http://ozmm.org/posts/git_post_commit_for_profit.html Tells you how to go about making a post-commit hook, more Ruby-specific though. It looks like you just add a script to execute in .git/hooks/post-commit, and git will run it after you commit. It could be a script that even runs a script in your git repo.

For the script, I would recommend just scanning with find, convert the filename to UTF-8, see if it's already that name, and if not, move it.

2
  • but is post-commit the right hook? I was thinking I had to convert (on linux) from cp1252 to utf8 after receiv files aingnd back to cp1252 before commiting or comparing files to the other repository (as linux machines are a minority in the network -- and convmv is easily installable in *buntu)...
    – Massa
    Mar 25, 2009 at 23:32
  • 1
    pre-commit looks promising. see: git-scm.com/book/en/Customizing-Git-Git-Hooks
    – tessi
    Jun 20, 2013 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.