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

Special characters in filenames are not properly encoded #110

Open
Wikiwix opened this issue Aug 18, 2024 · 10 comments
Open

Special characters in filenames are not properly encoded #110

Wikiwix opened this issue Aug 18, 2024 · 10 comments

Comments

@Wikiwix
Copy link
Contributor

Wikiwix commented Aug 18, 2024

If filenames contain non-ASCII characters this can lead to unexpected commit message suggestions. See for example this screenshot:

image

@MichaelCurrin
Copy link
Owner

hmm thanks. I was able to reproduce

but when I added unit tests, they pass.

e.g.

    describe("handle special characters in filenames", function () {
      it("should correctly parse a filename with special characters", function () {
        const expected: FileChange = {
          x: "A",
          y: " ",
          from: "abcëxyz.md",
          to: "",
        };

        assert.deepStrictEqual(parseDiffIndex("A\tabcëxyz.md"), expected);
      });
    });

@MichaelCurrin
Copy link
Owner

MichaelCurrin commented Aug 19, 2024

The problem is the git commands. I'll keep looking at this

$ npm run sb
$ cd sandbox
$ git add sp*
$ git ls
README.md
bazz.js
buzz.js
fizz.js
foo.js
"sp\303\253cial ch\303\242racters.md"

@MichaelCurrin
Copy link
Owner

Can you do this in your repo or globally across repos with --global?

git config core.quotePath false

Then try again and let me know if that works?

I started implementing a fix in the code but it touched a couple of files and then at some point the sandbox won't start beacuse of some error in vs code so I am stuck for now

@Wikiwix
Copy link
Contributor Author

Wikiwix commented Aug 19, 2024

@MichaelCurrin With core.quotePath false it behaves as expected.
If you call git within your code, you might simply want to add the matching config parameter using -c like in the following example:

git -c 'core.quotePath=false' ls-files

@MichaelCurrin
Copy link
Owner

from my quick testing it looks like that works.

image

@MichaelCurrin
Copy link
Owner

MichaelCurrin commented Aug 20, 2024

I've pushed the change on master if you want to build and install locally

git clone ...
make all
make e

I am not going to publish the change yet as a new version of the extension

@MichaelCurrin
Copy link
Owner

Hi, I've published a new version

@Wikiwix
Copy link
Contributor Author

Wikiwix commented Nov 3, 2024

Nice, but for me the new version throws this error (on Windows)

2024-11-03 19:51:18.261 [error] Error: Command failed: git -c 'core.quotePath=false' diff-index --name-status --find-renames --find-copies --no-color --cached HEAD
error: invalid key: 'core.quotePath
fatal: unable to parse command-line config

	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:519:28)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5) commitMsg.autofill {"value":"MichaelCurrin.auto-commit-msg","_lower":"michaelcurrin.auto-commit-msg"}

Running the command from the error message works as expected in Powershell…

@Wikiwix
Copy link
Contributor Author

Wikiwix commented Nov 3, 2024

In CMD I can recreate the error:

C:\Users\phili\dev\philips-wiki>git -c 'core.quotePath=false' diff-index --name-status --find-renames --find-copies --no-color --cached HEAD
error: invalid key: 'core.quotePath
fatal: unable to parse command-line config

Using double quotes or no quotes at all works though

EDIT: Single Quotes in CMD are just regular characters, so it is expected to not work in cmd

@Wikiwix
Copy link
Contributor Author

Wikiwix commented Nov 3, 2024

@MichaelCurrin I prepared #114 with a fix

And by now I am sorry that I did not build the earlier version myself and test it. Then the (on Windows) broken release could have been prevented :/

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

2 participants