-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Gutter diff adapts to git's core.autocrlf setting#3909
Open
MiguelRoldao wants to merge 1 commit intomicro-editor:master from
Open
Gutter diff adapts to git's core.autocrlf setting #3909MiguelRoldao wants to merge 1 commit intomicro-editor:master from
MiguelRoldao wants to merge 1 commit intomicro-editor:master from
Conversation
Author
MiguelRoldao
commented
Nov 12, 2025
This could possibly be simplified to a single:
shell.ExecCommand("git", "-C", dirName, "cat-file", "--filters", "HEAD:./" .. fileName)
But I'm not fluent in git to the extent of being able to guarantee that this would be equivalent to git show in all other cases.
Comment on lines
-13
to
+22
local diffBase, err = shell.ExecCommand("git", "-C", dirName, "show", "HEAD:./" .. fileName)
local autocrlf, err = shell.ExecCommand("git", "-C", dirName, "config", "get", "core.autocrlf")
local diffBase
if not err and string.match(autocrlf, "true") then
diffBase, err = shell.ExecCommand("git", "-C", dirName, "cat-file", "--filters", "HEAD:./" .. fileName)
else
diffBase, err = shell.ExecCommand("git", "-C", dirName, "show", "HEAD:./" .. fileName)
end
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use
diffBase, err = shell.ExecCommand("git", "-C", dirName, "cat-file", "--filters", "HEAD:./" .. fileName)
regardless of autocrlf?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Using micro on windows is very annoying, since the diff gutter will be filled with "modified", on git versioned files.
The diff in micro is calculated between the last commit in the repository and the active workspace. However, if the option core.autocrlf is enabled on windows, if the file in the repo has LF line endings, the file in the workspace will have CR LF line endings. Resulting in a detectable modification in every line of the file.
My solution checks if core.autocrlf is enabled. If it's not, if processes the diff normally. If it is enabled, the diff is calculated using
git cat-file --filters, to filter out the line end changes.This PR should solve issue #1517