Skip to content

Dunk fails when Git config "diff.mnemonicPrefix" is enabled #27

@alexbarton

Description

@alexbarton

When diff.mnemonicPrefix is enabled, dunk fails with errors like this:

❯ git config --global diff.mnemonicPrefix
true
❯ git diff | dunk
Traceback (most recent call last):
  File "/home/alex/.local/bin/dunk", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/alex/.local/share/uv/tools/dunk/lib/python3.12/site-packages/dunk/dunk.py", line 83, in main
    _run_dunk()
  File "/home/alex/.local/share/uv/tools/dunk/lib/python3.12/site-packages/dunk/dunk.py", line 132, in _run_dunk
    target_code = target_file.read_text()
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/pathlib.py", line 1027, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/lib/python3.12/pathlib.py", line 1013, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/Alex/WIP/Dunk/i/xyz/…'

Filename redacted, but basically it does not recognise the other prefixes than a/ and b/ in the git diff output:

diff --git i/.vim/spell/alex.utf-8.add w/.vim/spell/alex.utf-8.add
index 494d43d..55b615e 100644
--- i/xyz/…/file
+++ w/xyz/…/file

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