Special characters in filenames are not properly encoded · Issue #110 · MichaelCurrin/auto-commit-msg · GitHub
Skip to content

Special characters in filenames are not properly encoded #110

Open

Description

@Wikiwix

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

image

Activity

  1. MichaelCurrin commented on Aug 19, 2024

    @MichaelCurrin
    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);
          });
        });
    
  2. MichaelCurrin commented on Aug 19, 2024

    @MichaelCurrin
    Owner

    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"
  3. MichaelCurrin commented on Aug 19, 2024

    @MichaelCurrin
    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

  4. Wikiwix commented on Aug 19, 2024

    @Wikiwix
    ContributorAuthor

    @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
  5. MichaelCurrin commented on Aug 20, 2024

    @MichaelCurrin
    Owner

    from my quick testing it looks like that works.

    image

  6. MichaelCurrin commented on Aug 20, 2024

    @MichaelCurrin
    Owner

    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

  7. MichaelCurrin commented on Nov 3, 2024

    @MichaelCurrin
    Owner

    Hi, I've published a new version

  8. Wikiwix commented on Nov 3, 2024

    @Wikiwix
    ContributorAuthor

    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…

  9. Wikiwix commented on Nov 3, 2024

    @Wikiwix
    ContributorAuthor

    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

  10. Wikiwix commented on Nov 3, 2024

    @Wikiwix
    ContributorAuthor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions