Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.77k stars 288 forks source link

[Bug]: CRLF would be replaced by LF #164

Open feremabraz opened 2 years ago

feremabraz commented 2 years ago

Describe the bug

Whenever I try to stage files, I get the following notification. I'm on Linux. What should I do? Screenshot from 2022-01-16 18-56-02

Relevant errors (if available)

No response

Steps to reproduce

Use this plugin in any Linux machine or VM.

Expected Behavior

No response

Addition context

No response

Operating system

Linux

Vinzent03 commented 2 years ago

I think you have some windows files in your vault. May try the solution provided on stackoverflow

ooker777 commented 2 years ago

I use Obsidian on a Windows computer and an Android phone. I follow the article Using Obsidian Git for the tech unfamiliar (minimal command line usage to set up git. I then use

git config core.autocrlf true

on my root folder. But this is still happening. Do you know why?

ooker777 commented 2 years ago

@Vinzent03 Hello. Would you mind if I bump this again?

Vinzent03 commented 2 years ago

@ooker777 The Stack Overflow answer is to set it to false. You set it to true.

mattcoleanderson commented 1 year ago

@Vinzent03 the stackoverflow answer you are quoting is for linux users. Windows users should use true because true will convert LF to CRLF.

However, from my own testing, the Obsidian client defaults to LF and automatically converts all CLRF control characters to LF on editing a file.

So regardless of if you are on Windows, Mac, or Linux its best to set git config core.autocrlf false

zoujia commented 1 year ago

@Vinzent03 the stackoverflow answer you are quoting is for linux users. Windows users should use true because true will convert LF to CRLF.

However, from my own testing, the Obsidian client defaults to LF and automatically converts all CLRF control characters to LF on editing a file.

So regardless of if you are on Windows, Mac, or Linux its best to set git config core.autocrlf false

Solve my problem~๐Ÿ‘๐Ÿ‘

jrob commented 1 year ago

This is definitely a bug. I have been using autocrlf true for many years as it saves a lot of headache when moving sharing code between different people and on different operating systems. Setting autocrlf false is not an option for me. I have written a small script to convert line endings to lf since Logseq (which lives in the same directory) is, correctly, using crlf for it's line endings.

Vinzent03 commented 1 year ago

This plugin only executes git commands like you would on the terminal. So this plugin doesn't affect the line endings. So I'm not quite sure where the issue lies.

jrob commented 1 year ago

My apologies, this is not a bug with the plug in. It's a bug that should be owned by obsidian. This issue should be closed.

darthwalsh commented 8 months ago

This Obsidian Forum post is a feature request to change the current behavior of Obsidian on Linux always using LF endings (give it a Like and maybe they'll fix it).

A different forum post Windows and Mac syncing broken because of newline characters agrees with git config core.autocrlf false as the workaround for now. Maybe the plugin could scan the git output for this warning ("CRLF would be replaced by LF") and print a helpful message?

rmunn commented 6 months ago

@jrob wrote:

This is definitely a bug. I have been using autocrlf true for many years as it saves a lot of headache when moving sharing code between different people and on different operating systems. Setting autocrlf false is not an option for me.

You'll want to use git config --local core.autocrlf false. That way the setting will be stored in the .git/config file in your Obsidian repo, and will only apply to that repo, with your global core.autocrlf option applying in every other repo. That's specifically what the --local option is for, so you can have global git configs with sensible defaults and override those defaults on a case-by-case basis for repositories that need a slightly different config. See https://git-scm.com/docs/git-config#FILES for more details.