开发者

egg git interface for emacs, commit message empty

开发者 https://www.devze.com 2022-12-24 22:28 出处:网络
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\".

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 thi开发者_运维技巧nk 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?


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 :)


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消