当 TextMate 退出时,Mac 上的 git commit -a 会挂起
我将 core.editor 设置为“mate -w”。在 Leopard 上, git commit -a 启动 TextMate。输入提交日志消息、保存(Cmd-S)并退出(Cmd-Q)TextMate 后,git 将使用输入的提交日志消息成功完成提交操作。
自从升级到 Snow Leopard (Mac OS X 10.6.2) 以来,行为发生了变化。退出 TextMate 后,git commit 挂起(消耗 0% CPU),需要使用 Ctrl-C 取消。
如果未设置 core-editor 并且 $EDITOR 设置为“mate”或“mate -w”,也会发生同样的情况。
解决方法是在保存提交日志消息后按 Ctrl-W 而不是 Ctrl-Q 来退出当前的 TextMate 窗口,但我想了解行为上的差异(特别是当我的手指现在接受了 Cmd- 训练时) S Cmd-Q 序列)并进行修复,因为许多其他人可能会遇到此问题。
#git IRC 频道(在 git 主页 上引用)提供了一些帮助。他们让我将 $GIT_TRACE 设置为 1,显示以下跟踪:(
git commit -a
trace: built-in: git 'commit' '-a'
trace: run_command: 'sh' '-c' 'mate -w "$@"' 'mate -w' '.git/COMMIT_EDITMSG'
^C
另外,在过去运行 Leopard 的另一台 Mac 上,git commit 在我退出 TextMate 后会继续,但随后 git 找不到提交日志消息,它会中止提交。这似乎是一个明显的问题,但它暗示 git commit 和编辑器之间的交互不完善。)
I have core.editor set to "mate -w". On Leopard, git commit -a starts TextMate. After entering a commit log message, saving (Cmd-S), and quitting (Cmd-Q) TextMate, git would successfully complete the commit operation using the entered commit log message.
Since upgrading to Snow Leopard (Mac OS X 10.6.2), the behaviour has changed. After quitting TextMate, git commit hangs (consuming 0% CPU) and needs to be cancelled with Ctrl-C.
The same happens if core-editor is not set and $EDITOR is set to "mate" or "mate -w".
A workaround is to quit just the current TextMate window by hitting Ctrl-W rather than Ctrl-Q after saving the commit log message, but I'd like to understand the difference in behaviour (especially as my fingers are now trained with the Cmd-S Cmd-Q sequence) and get a fix as many other people are likely to run into this.
The #git IRC channel (referenced on the git home page) was some help. They got me to set $GIT_TRACE to 1 which showed the following trace:
git commit -a
trace: built-in: git 'commit' '-a'
trace: run_command: 'sh' '-c' 'mate -w "$@"' 'mate -w' '.git/COMMIT_EDITMSG'
^C
(Also, on another Mac running Leopard in the past, git commit used to continue after I quitted TextMate, but then git would not find the commit log message and it would abort the commit. This seems to be a distinct problem, but it hints that the interaction between git commit and the editor is imperfect.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设它与 TextMate 关闭文件的方式有关,尽管我无法理解具体细节。
mate
的-w
标志表示“等待 TextMate 关闭文件”(mate
的通常行为是让 TextMate 打开文件,然后退出)。这允许 TextMate 用作$EDITOR
。我想当 TextMate 退出(通过 TextMate -> Quit)时,它会绕过mate
程序“等待”的某种机制,但我不知道详细信息。您可能更幸运地联系 TextMate 邮件列表,而不是 Git 邮件列表,因为这可能是一个 TextMate的东西,不是 Git 的东西。I'm assuming it has something to do with the way TextMate closes the file, although I can't fathom the specifics.
mate
's-w
flag means "wait for TextMate to close the file" (the usual behavior ofmate
is to have TextMate open the file, then exit). This allows TextMate to be used as an$EDITOR
. I suppose when TextMate exits (via TextMate -> Quit) it bypasses some mechanism by which themate
program "waits", but I don't know the details. You may have more luck contacting the TextMate mailing list, rather than the Git mailing list, since this is probably a TextMate thing, not a Git thing.根据 TextMate 邮件列表上的回复,似乎很可能这个问题的根源在于 Cocoa 框架处理应用程序关闭的方式。
Leopard 和 Snow Leopard 之间的行为可能发生了变化,导致负责与“mate”通信的对象不再被正确破坏,并且调用者 git commit 挂起。
According to a response on the TextMate mailing list, it seems likely that the source of this problem is the way the Cocoa framework handles application shutdown.
The behaviour probably changed between Leopard and Snow Leopard such that the object responsible for communicating with 'mate' is no longer properly destructed and the caller, git commit, hangs.
我已经为此苦苦挣扎了好几天,这让我快要发疯了。我刚刚找到了罪魁祸首,我将在这里记录下来,希望能减轻其他人的痛苦。
在某些时候,我将 ~/.gitconfig ~/.gitignore-global 移动到一个小的 git 存储库中,我用它来存储我的点文件,并从我的主目录符号链接到存储库中。此外,该存储库存储在 Dropbox 磁盘上。 (旁注:一般来说,将 git 存储库保留在 DropBox 中是个坏主意 - 我可以从个人经验中证明 - 但这既不在这里也不在那里。)
无论如何,我已经诉诸于筛选 dtruss 输出试图找出为什么我不能不再使用 textmate 提交,我看到了这一点并将文件移回到我的主目录中。正确的行为立即恢复。
恐怕我不知道是否是 a) 符号链接 b) Dropbox c) 两者的组合破坏了一切,并且在上面浪费了这么多时间,我必须回去工作。但这应该会给你一些尝试的机会。
I have been struggling with this for days and it was driving me stark raving mad. I just now found the culprit which I will document here hoping to alleviate someone else's suffering.
At some point I moved my ~/.gitconfig ~/.gitignore-global into a little git repository I use to store my dotfiles, and symlinked from my home directory into the repository. Furthermore, the repo was stored on a Dropbox disk. (Side note: bad idea in general to keep git repos in DropBox - I can attest from personal experience - but that's neither here nor there.)
In any case, having resorted to sifting through dtruss output trying to find out why I couldn't commit with textmate anymore, I saw this and moved the files back into my home directory. Correct behavior returned immediately.
I'm afraid I don't know whether it was a) the symlinking b) Dropbox c) the combination of both which broke things, and having wasted this much time on it I must go back to work. But that ought to give you something to try.