emacs 的 Egg git 接口,提交消息为空

发布于 2024-08-26 20:15:31 字数 425 浏览 9 评论 0原文

我使用egg(emacs有git)作为emacs中的git接口。 每当我尝试实现提交 --amend 时,我都会收到 “GIT-COMMIT-AMEND> 由于空提交消息而中止提交”。

这就是我所做的:

C-u C-x v c

然后出现提交缓冲区,并带有我之前提交的消息。

然后,在抄送后,我收到上述消息:空提交消息。

我想我以前在常规提交中也遇到过这种行为(如不修改),但不记得或找不到我是如何解决它的。

我尝试编辑该消息(在某​​处添加空格)。没有工作。

我尝试在提交之前保存缓冲区,但这也不起作用(因为 Cc Cc 在提交缓冲区之外的另一个缓冲区中不处于活动状态)。

有什么线索吗?

I'm using egg (emacs got git) as git interface in emacs.
Whenever I try to achieve a commit --amend, I receive a "GIT-COMMIT-AMEND> Aborting commit due to empty commit message".

This is what i do:

C-u C-x v c

Then the commit buffer appears, with the message of my previous commit.

Then upon C-c C-c I get the message stated above: empty commit message.

I think I've had this behaviour with regular commits (as in not amend) before, but can't remember or find how I solved it.

I tried editing the message (adding a space somewhere). No work.

I tried saving the buffer before committing, that wouldn't work either (since C-c C-c is not active in another buffer than the commit buffer).

Any clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

哥,最终变帅啦 2024-09-02 20:15:31

这是因为 emacs 尝试打开编辑器进行 commit --amend 吗?请参阅此交流

[06:28:18] 问题:这是我第一次使用 git 提交。我期望“git commit”允许我输入提交消息,但它却在 TextWrangler 中打开 .git/COMMIT_EDITMSG (我使用的是 Mac)并且终止提交,并显示“由于提交消息为空而中止提交。”我做错了什么?

[06:29:24]burningdog:可能TextWrangler在打开时与外壳分离。这会导致 git 在编辑器打开时认为您已完成提交消息。

[06:30:10] Ilari:嗯……听起来不错。 /usr/bin/edit 将通过管道传送给它的任何内容发送到 TextWranger。也许我可以改变这一点...

[06:30:27]burningdog:要么设置一些选项告诉不要这样做。否则将提交消息写入文件,然后使用 -F 提交。

[06:31:26] Ilari:当用户输入提交消息时 git 调用 /usr/bin/edit 是否是预期行为?

[06:32:09] 它使用很少的设置来确定要打开的编辑器。

[06:32:54] 啊,这样默认文本就会在some编辑器中打开。明白了。

[06:34:06]burningdog:core.editor $GIT_EDITOR $VISUAL$EDITOR

[06:34:31] Ilari:我更改了 bash 配置文件以使用 pico 作为编辑器 - 修复了该问题。感谢您的帮助:)

Is this because of the editor emacs try to open for a commit --amend? See this exchange

[06:28:18] <burningdog> question: This is my first commit with git. I expected "git commit" to allow me to type a commit message in, but instead it opens up .git/COMMIT_EDITMSG in TextWrangler (I'm on a Mac) and terminates the commit, saying "Aborting commit due to empty commit message." What am I doing wrong?

[06:29:24] <Ilari> burningdog: Probably TextWrangler detaches from the shell when opening. This causes git to think you finished with the commit message when the editor opens.

[06:30:10] <burningdog> Ilari: hmmm...that sounds about right. /usr/bin/edit sends whatever is piped to it to TextWranger. Maybe I can change that...

[06:30:27] <Ilari> burningdog: Either put some option telling not to do it. Otherwise write commit message to file and then use -F <file> to commit.

[06:31:26] <burningdog> Ilari: is it expected behaviour that git calls /usr/bin/edit when a user enters a commit message?

[06:32:09] <Ilari> There are few settings it uses to determine what editor to open.

[06:32:54] <burningdog> ah, so that default text is opened in some editor. Got it.

[06:34:06] <Ilari> burningdog: core.editor $GIT_EDITOR $VISUAL and $EDITOR

[06:34:31] <burningdog> Ilari: I changed my bash profile to use pico as the editor - fixed that. Thanks for your help :)

抚你发端 2024-09-02 20:15:31

问题解决了,虽然不太明白。

我不得不改变鸡蛋的一些选项。在某些情况下,它似乎没有正确的字符串来查找 git.exe。

我做了什么:

M-x customize-group <RET> egg <RET>

然后将 Egg git 命令 更改为 git.exe 包括其完整路径

这有点奇怪,因为:

  • Egg 可以使用 git 生成状态缓冲区
  • git 的路径在我的路径 envvar 中
  • 我相信消息“中止提交...”来自 git。

在学习了如何调试 elisp 后,我发现在函数 egg-log-msg-commit 中,应该显示提交消息限制的标记都是 nil

在其他地方,这些标记保存提交消息的字符索引,但不在那里。

Problem solved, although I do not quite understand.

I had to change some options for egg. It didn't seem to have the correct string to find git.exe in some cases.

What I did:

M-x customize-group <RET> egg <RET>

then changing Egg git command to git.exe including its full path worked.

This is a bit strange since:

  • egg could use git to generate the status buffer
  • the path to git is in my path envvar
  • the message "Aborting commit..." comes from git, I believe.

After learning how to debug elisp, I found that the markers supposed to show the limits of the commit message were both nil in the function egg-log-msg-commit.

At other places, these markers hold the character indexes for the commit message, but not there.

不再让梦枯萎 2024-09-02 20:15:31

我只是尝试使用 PsPad 作为提交编辑器,但没有成功。它失败并出现相同的错误消息。这里的问题是 git 像这样调用它的编辑器:

[Path]\PsPad.exe .git/COMMIT_EDITMSG

但是 PsPad 无法使用“/”解析该路径,这导致 PsPad 在存储库根文件夹中而不是在子文件夹“.git”中打开文件 COMMIT_EDITMSG 。
我不使用 emacs/egg 所以我无法重现你的问题,但也许这些信息也有帮助。

对于 PsPad 用户:我通过使用此包装脚本调用 PsPad 解决了我的问题:

"C:\Programme\PsPad editor\PsPad" $(echo $1 | sed 's/\//\\/')

该代码行包含在用作 git 编辑器的批处理文件中。它只是用“\”替换所有“/”,这使得 PsPad 被这样调用:

[Path]\PsPad .git\COMMIT_EDITMSG

I just tried to use PsPad as commit editor which didn't work. It failed with the same error message. The problem here is that git calls its editor like that:

[Path]\PsPad.exe .git/COMMIT_EDITMSG

But PsPad isn't able to parse that path with a '/', which results in PsPad opening a file COMMIT_EDITMSG in the repository root folder rather than in the subfolder '.git'.
I don't use emacs/egg so I cannot reproduce your problem, but maybe that information also helps.

For PsPad users: I solved my problem by using this wrapper script to call PsPad:

"C:\Programme\PsPad editor\PsPad" $(echo $1 | sed 's/\//\\/')

That code line is contained in a batch file which is used as git editor. It simply replaces all '/' by '\', which makes PsPad being called like that:

[Path]\PsPad .git\COMMIT_EDITMSG
ぽ尐不点ル 2024-09-02 20:15:31

我在 Windows 上使用 MSYS git。设置实际 git.exe 的路径为我解决了这个问题。 (对我来说,正确的路径是:'c:\Program Files\Git\bin\git.exe')。

默认情况下,MSYS git 添加到路径 git.cmd,这显然会猜测 git.exe 的位置等。我认为这不知何故弄乱了与 emacs 的连接。

编辑:上述方法有一个缺陷。 git.cmd 显然设置了 home 环境变量。一些 git 设置写在那里。当与 emacs 一起使用时,git.exe 将从 emacs 接收环境。因此,建议确保 git 从命令行执行时具有与 emacs 相同的主目录。

我个人通过在启动期间更改 HOME 环境变量在 emacs 配置中修复了此问题,但这会产生一些副作用,例如编辑 .emacs 文件。

I'm using the MSYS git on Windows. Setting the path to the actual git.exe fixed this issue for me. (For me the correct path was: 'c:\Program Files\Git\bin\git.exe').

By default MSYS git adds to the path git.cmd, which will apparently guess the location of the git.exe, among other things. Somehow this messes up the connection with the emacs, I think.

EDIT: There is one flaw in the approach above. The git.cmd apparently sets up home environment variable. Some of the git settings are written there. When used with emacs, the git.exe will receive the environment from emacs. So, it would be advisable to make sure that git, when executed from command line, has the same home dir as emacs.

I've personally fixed this in emacs config by changing the HOME environment variable during the start-up, but this has some side effects regarding, e.g., editing your .emacs file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文