sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.93k stars 107 forks source link

[bug] diffview index buffer always unix file format #384

Open benjaminBrownlee opened 1 year ago

benjaminBrownlee commented 1 year ago

Description

If you open diffview in a repository with files in dos format, the buffer holding contents of the file in the index (on the left for changes, on the right for staged changes), is always in unix format. If you modify and write this buffer, you will change the file format and thus appear to have changed every line in this git revision.

Using the file browser to stage entire files (pressing - in the left sidebar does not appear to have this problem. Consequences only occur if you save the index buffer manually.

Expected behavior

Buffers containing the index state of a file should be consistent with its format in the local repository and workspace.

Actual behavior

The index buffer is always unix format.

Steps to reproduce

  1. Create a git repository and add a file containing some text. Save it in the dos format.
  2. Commit the file to history.
  3. Modify the file in some manner.
  4. Run :DiffviewOpen. Note the file format of the index is unix while the workspace is dos.
  5. Modify the index buffer and save.
  6. Observe with git dif --staged that the file format has been changed and every line appears in the diff.

Health check

Output of :checkhealth diffview ``` diffview: require("diffview.health").check() Checking plugin dependencies ~ - OK nvim-web-devicons installed. Checking VCS tools ~ - The plugin requires at least one of the supported VCS tools to be valid. - OK Git found. - OK Git is up-to-date. (2.41.0) - WARNING Configured `hg_cmd` is not executable: 'hg' ```

Log info

Relevant info from :DiffviewLog ``` # No relevant log info. ```

Neovim version

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

Linux 6.3.8-arch1-1 x86_64 GNU/Linux

Minimal config

-- no particular configuration is require to reproduce this