Skip to content

Conversation

@gadfly3173
Copy link
Contributor

In certain cases, when handling merges and conflicts through SourceGit on Windows, an undeletable NUL file may appear. I believe this is related to the code's fixed usage of /dev/null, hence I created this PR. However, I haven't found a stable way to reproduce this issue. I can only confirm that this modification doesn't affect diff operations effect.

@love-linger
Copy link
Collaborator

我并不认为需要为Windows平台单独处理 /dev/null (从 git 源码中可以看到即使是在 Windows 平台,/dev/null 也是被支持的),而且 NUL 文件的产生应该是其他问题导致的。我本地未发现过该文件的产生。

  • git 源码中支持 /dev/null,只是在 Windows 平台增加了 nul 的支持(不确定该特性是否被 ssh 命令支持)

https://github.com/git/git/blob/8745eae506f700657882b9e32b2aa00f234a6fb6/diff-no-index.c#L81-L92

  • GitExtensions 使用 /dev/null

https://github.com/gitextensions/gitextensions/blob/2662d7e57f5cf420c79761c94137836bf63c2531/src/app/GitCommands/Git/RevisionDiffProvider.cs#L108-L121

@love-linger
Copy link
Collaborator

顺便问一下,你是否配置了外部对比工具?是哪个呢?

@gadfly3173
Copy link
Contributor Author

https://gitlab.com/tortoisegit/tortoisegit/-/blob/master/src/TortoiseMerge/Patch.cpp#L205-206 tortoisegit 是加了的,我也不是很确定问题的原因。

我使用的是sourcegit中默认的vscode配置。

@gadfly3173 gadfly3173 closed this Jan 13, 2026
@love-linger
Copy link
Collaborator

我本来猜测是在使用外部工具对比时会产生该问题。因为 git difftool 调用外部工具会传入两个文件的路径(比如某个版本的文件,它会在 temp 目录保存一份该版本的文件,用于第三方工具打开),而对于空文件,我不太清楚它的处理方式,后面细看一下,但粗看了一下 tortoisegit 的对比,它是这样的:

image

@gadfly3173 gadfly3173 deleted the fix/windows-nul branch January 14, 2026 02:13
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