Skip to content

Fix: diff-hl-magit-post-refresh wrong file name#280

Merged
dgutov merged 2 commits into
dgutov:masterfrom
danielfleischer:patch-1
Jun 5, 2026
Merged

Fix: diff-hl-magit-post-refresh wrong file name#280
dgutov merged 2 commits into
dgutov:masterfrom
danielfleischer:patch-1

Conversation

@danielfleischer

@danielfleischer danielfleischer commented May 26, 2026

Copy link
Copy Markdown
Contributor

git diff-tree is used and generates relative (to top level) file names.
buffer-file-name generates full paths.

The following condition always fails due to the file names being different:

((member file modified-files)

This fixes the refresh related to magit actions.

`git diff-tree` is used and it generated relative file names. `buffer-file-name` generates full paths. Condition check always fails due to these being different.
@dgutov

dgutov commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Hi!

(file-name-nondirectory file) will return the file name stripped of all directory parts.

Maybe you wanted to use file-relative-name?

I suggest you also add a message in there printing the values on mismatch and post it the result here (with the fix not applied yet). To document the failure as it happens.

- Use `file-relative-name` instead of `file-name-nondirectory` to
properly match files in subdirectories against `modified-files`
@danielfleischer

Copy link
Copy Markdown
Contributor Author

Thank you.

First, you are correct, I focused on top-level when testing. Fixed in 581c577.

Second, when debugging the cond branch with:

(or
 (member file modified-files)
 (ignore (message "FILE %s NOT IN %s" file modified-files)))

one gets:

FILE /Users/dan/Documents/Projects/my_project/fileA NOT IN (fileA)

hence the filename normalization.

@dgutov
dgutov merged commit ca4391f into dgutov:master Jun 5, 2026
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

Successfully merging this pull request may close these issues.

2 participants