gpt4 book ai didi

macos - 如何防止 NUL 字节出现在我的 GIT 存储库和提交消息中?

转载 作者:太空狗 更新时间:2023-10-29 12:51:22 27 4
gpt4 key购买 nike

我有一个相对干净的 Mac OS X Mavericks 10.9 安装,运行 git 版本 1.8.5.1;我的文件在已安装的 SMB 共享上,我无法再使用我的 GIT 存储库正常工作,因为 NULL 字节 (\0's) 不断出现在我所有的版本控制文件中......甚至在动态生成的文件中由 GIT 提供。

手动输入 git commit -m "Test message",得到:

error: a NULL byte in commit log message not allowed.
fatal: failed to write commit object

如果我尝试 git commitpico View 中显示的默认提交消息如下所示:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch feature/centos_support
# Your branch is up-to-date with 'origin/feature/centos_support'.
#
# Changes to be committed:
# modified: README.md
#
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

有一段时间,手动删除末尾的那些 NULL 字节有效,我能够提交,但有时甚至这不再有效(错误与上面相同),我被迫丢弃我的整个 repo 、重新克隆它,然后重做我试图提交的任何内容。

新的存储库在一段时间内正常工作,但最终 NULL 字符又回来了,我又遇到了同样的问题。

相同的 NULL 字节(如上所述)出现在我修改的文件的开头和结尾,导致 GIT 将它们视为二进制文件,直到我手动使用 vi 删除 NULL 行。

  • 有没有其他人遇到过这种情况,和/或找到了解决方案?
  • 可能是什么原因造成的?

如果您能提供任何帮助,我将不胜感激。

最佳答案

看起来这是 OS X 10.9 Mavericks 和(某些?)SMB 共享的问题。目前没有修复或解决方法。

有些人建议使用 cifs://而不是 smb://连接到共享,但这似乎无法解决问题。

问题可以重现如下:

<on an SMB share>

$ echo "blah blah blah blah" > test.txt
$ more test.txt

<file is fine>

$ echo "blah" > test.txt
$ more test.txt

<file has ^@ characters at the end>

因此,使用终端,如果您用较小的文件覆盖一个文件,那么您会在末尾得到这些 NUL 字符。可能还有其他方法也可以使文件附加或添加这些 NUL 字符。

很多人都在提示这个,例如: https://netbeans.org/bugzilla/show_bug.cgi?id=237766

这是该页面的结论:

I can replicate the null characters in Komodo Edit and Aptana Studio, so this doesn't appear to be a Netbeans specific issue, and is probably related to the NAS/SMB issue.

I forced the smb1 connection but it made no difference. Even if I eject the shares, and reconnect with cifs:// and create, modify and save a file, it's still corrupted.

It looks like Apple is going to have to resolve this, unless someone can come up with a viable workaround.

希望 Apple 能尽快解决这个问题。在那之前,您可能会使用 Double Commander 或其他实现自己的 SMB 堆栈的程序。

关于macos - 如何防止 NUL 字节出现在我的 GIT 存储库和提交消息中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20696643/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com