简体   繁体   English

使用 SVN Diff 时,Ubuntu Linux 上带有行尾样式的 WinSCP 问题

[英]Problems with WinSCP with end-of-line style on Ubuntu Linux when using SVN Diff

My files are on a remote Ubuntu Linux server.我的文件位于远程 Ubuntu Linux 服务器上。 When I download the files and edit it in either the WinSCP text editor or Notepad++, the file end-of-line style changes to Windows.当我下载文件并在 WinSCP 文本编辑器或 Notepad++ 中编辑它时,文件行尾样式更改为 Windows。 So when I resave the file back to Ubuntu the lines are off and SVN Diff thinks every line has changed.因此,当我将文件重新保存回 Ubuntu 时,这些行已关闭,并且 SVN Diff 认为每一行都已更改。

FYI, I edit the file by double clicking the file in WinSCP.仅供参考,我通过双击 WinSCP 中的文件来编辑文件。 This program launches the file in the editor.该程序在编辑器中启动文件。 Every time I save, the file is automatically copied back to the Linux server.每次保存时,文件都会自动复制回 Linux 服务器。

How do I prevent the end-of-line style issue?如何防止行尾样式问题?

Does this thread help?这个线程有帮助吗? More precisely this part:更准确地说,这部分:

From this, it seems to me that you have forced WinSCP to use text mode transfer, which imply the unix->dos conversion.由此看来,你强迫 WinSCP 使用文本模式传输,这意味着 unix->dos 转换。 Just force the binary mode to avoid the conversion.只需强制使用二进制模式即可避免转换。

I wasn't able to figure out why I had the whitespace issue but I was able to figure out how to ignore whitespaces.我无法弄清楚为什么我有空格问题,但我能够弄清楚如何忽略空格。

You can use:您可以使用:

svn diff -x'-uw --ignore-eol-style'

This worked well enough.这工作得很好。

You need to use the unix line format.您需要使用 unix 行格式。 To set this, go to Settings>Preferences and select the "New Documents/Default Directory" tab.要设置此项,请转到设置>首选项并选择“新文档/默认目录”选项卡。 Find "Format" in the "New Document" controls and select "Unix".在“新建文档”控件中找到“格式”并选择“Unix”。 This will ensure any new document has the correct format.这将确保任何新文档都具有正确的格式。 I have used this with a remote linux server and have not seen a problem.我已经在远程 linux 服务器上使用了它,但没有发现问题。

Typically, the returned file would be created with a temporary name and the changes written to it.通常,返回的文件将使用临时名称和写入的更改创建。 The original file would then be removed and the new file renamed to take its place.然后将删除原始文件并重命名新文件以取代它。 This would make the returned file a "new" document so this preference setting should give the correct format.这将使返回的文件成为“新”文档,因此此首选项设置应提供正确的格式。

If you use text/ascii mode transfer with WinSCP, it would convert the end-of-line style back to Unix on upload.如果您在 WinSCP 中使用 text/ascii 模式传输,它将在上传时将行尾样式转换回 Unix。

So I guess the problem might be that your file actually has Windows end-of-line style initially.所以我想问题可能在于您的文件最初实际上具有 Windows 行尾样式。 On download, nothing changes, but on upload, it gets converted to Unix style.在下载时,没有任何变化,但在上传时,它会转换为 Unix 样式。

Either fix your file to use the Unix style as it should (if that's the case) or use the binary transfer mode.修复您的文件以使用 Unix 样式(如果是这种情况)或使用二进制传输模式。

Not only you need to configure the binary transfer mode for WinSCP in general (what is the default in recent versions of WinSCP), but you also need to make sure that the preference option Force text transfer mode for files edited in external editor for your external editor (Notepad++) is off:您不仅需要为 WinSCP 配置一般的二进制传输模式(WinSCP 最新版本的默认设置),而且您还需要确保在外部编辑器中外部编辑器编辑的文件的首选项选项强制文本传输模式编辑器 (Notepad++) 已关闭:
https://winscp.net/eng/docs/ui_editor_preferences https://winscp.net/eng/docs/ui_editor_preferences

Note that this option is not available for WinSCP internal editor.请注意,此选项不适用于 WinSCP 内部编辑器。 With it files are always transferred in the text/ascii mode.有了它,文件总是以 text/ascii 模式传输。

I use Notepand2 and WinSCP to edit files on Windows and server is on Linux.我使用 Notepand2 和 WinSCP 在 Windows 上编辑文件,服务器在 Linux 上。

In my case the problem was with WinSCP connection itself.就我而言,问题在于 WinSCP 连接本身。

I clicked "Edit" before the connection and then "Advanced" there was option for End-of-line characters.我在连接之前单击“编辑”,然后单击“高级”,有行尾字符选项。 Changing it solved the problem in my case.改变它解决了我的问题。

Option on the screen is already the one that worked.屏幕上的选项已经是有效的选项。 Ealier there was "LF" only.早期只有“LF”。

在此处输入图片说明

The simple and appropriate fix to that issue can be done by going into the configuration of your external editor in WinSCP可以通过在 WinSCP 中配置外部编辑器来完成对该问题的简单且适当的修复

In: View > Preferences > Editors在: View > Preferences > Editors

Select your external editor and click Edit ...选择您的外部编辑器,然后单击Edit ...

Then, uncheck: Force text transfer mode for files edited in external editor然后,取消选中: Force text transfer mode for files edited in external editor

This a supplement to Djidiouf's answer.这是对 Djidiouf 答案的补充。

  1. Go to WinSCP(ver.5.17.9) Options->Preferences->Editors转到 WinSCP(ver.5.17.9) Options->Preferences->Editors
    Uncheck Force test transfer mode for files edited in external editor取消选中Force test transfer mode for files edited in external editor 取消选中在外部编辑器中编辑的文件的强制测试传输模式

  2. Go to Session->Advanced->Environment->End-of-line characters转到Session->Advanced->Environment->End-of-line characters
    Select LF选择LF 应该选择LF

  3. Trying to pull a file from server, verifying its EOL-sytle尝试从服务器中提取文件,验证其 EOL 样式记事本++

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM