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

Disable Git's core.quotePath to fix usage with non-ASCII filenames. #31

Merged
merged 1 commit into from Nov 28, 2021

Conversation

okeeblow
Copy link
Contributor

Git's default configuration causes non-ASCII filename characters to be escaped
in git subcommand stdout, breaking git-crecord's parsing. In my case I don't have the option to just rename the file to an ASCII-compatible filename, because it's a test fixture for a file-type identification library where the filename is significant.

Before, when running crecord in my repository with an untracked non-ASCI-named file:

[okeeblow@emi#CHECKING YOU OUT] git config core.quotepath on 
[okeeblow@emi#CHECKING YOU OUT] git crecord                 
Traceback (most recent call last):
  File "/home/okeeblow/.local/bin/git-crecord", line 4, in <module>
    main()
  File "/home/okeeblow/Works/git-crecord/git_crecord/main.py", line 203, in main
    crecord_core.dorecord(ui, repo, None, **(opts))
  File "/home/okeeblow/Works/git-crecord/git_crecord/crecord_core.py", line 195, in dorecord
    return recordfunc(ui, repo, "", None, opts)
  File "/home/okeeblow/Works/git-crecord/git_crecord/crecord_core.py", line 54, in recordfunc
    chunks = crpatch.parsepatch(fp)
  File "/home/okeeblow/Works/git-crecord/git_crecord/crpatch.py", line 665, in parsepatch
    for newstate, data in scanpatch(fp):
  File "/home/okeeblow/Works/git-crecord/git_crecord/crpatch.py", line 77, in scanpatch
    raise PatchError('unknown patch content: %r' % line)
git_crecord.crpatch.PatchError: unknown patch content: 'diff --git "a/CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-roxio-toast/Toast 5.0.2 CHECKING YOU OUT\\342\\200\\242image" "b/CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-roxio-toast/Toast 5.0.2 CHECKING YOU OUT\\342\\200\\242image"\n'

I recreated the subprocess command used by crecord, and here is an example of the double-quoted diff --git "a/ line that's tripping it up:

diff --git "a/CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-roxio-toast/Toast 5.0.2 CHECKING YOU OUT\342\200\242image" "b/CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-roxio-toast/Toast 5.0.2 CHECKING YOU OUT\342\200\242image"
new file mode 100644
index 0000000000000000000000000000000000000000..2d59d302429c26160a1a31beb6a8d6e3e5ade577
GIT binary patch
literal 1067008
zcmeFa2V4{1zUVutl!!nSumWNs5(HFA6zPH#BP}6_)X+sBbfhRn5F#i=ic+J15Q+*2
z2nsf;<&RV&A_$5=L=X)fawq(E`R~0?+4r4y-@fmhEIyN2Gg(vCcm3L0vnJ@8K>+~Z

After this patch, where git-crecord works as expected:

Select hunks to commit - [x]=selected **=collapsed  c: confirm  q: abort  arrow keys: move/expand/collapse  space: deselect  ?: help
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/mac-compactpro/CYO.cpt
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/mac-compactpro/CYO.sea
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-appleworks-document/CYO.cwk
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-roxio-toast/Toast 5.0.2 CHECKING YOU OUT•image
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-stuffit/CYO.sit
[x]**A CHECKING YOU OUT/TEST MY BEST/Try 2 Luv. U/application/x-stuffitx/CHECKING YOU OUT.sitx

Git's default configuration causes non-ASCII filename characters to be escaped
in git subcommand stdout with the entire filename double-quoted,
breaking `git-crecord`'s subprocess stdout parsing.
@andrewshadura
Copy link
Owner

Thanks for your contribution, although I find it curious I never ran into this issue myself.
I appreciate the expanded comment you’ve put into the source code itself, but in future it’d be great if you also put it in its entirety into the commit message as well 🙂

@andrewshadura andrewshadura merged commit f520edf into andrewshadura:main Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants