tags:

views:

213

answers:

3

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?

+1  A: 

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

VonC
If I understand right, you suggest that my gitconfig having emacs as my editor would interfere with the commit?I changed the editor to notepad, but I still have the problem.
Gauthier
Note also that I do not see a new emacs session opening. There's no problem doing a `git commit --amend` from git bash. The message of the previous commit appears in the current emacs, as it should, it is just upon `C-c C-c` that things get strange.
Gauthier
@Gauthier: I have emphasized the important part about a shell being detached. That may be the cause here. But I have not the right environment to test it out.
VonC
Thanks. I'm not sure I understand though. The emphasized text mentions the editor of the commit message being detached from the shell. Here everything happens in emacs. I can understand that egg does its thing from emacs via an internal shell. The case described refers to the editor opening, then detaching therefore the shell thinks the commit message is finished. In my case the buffer for the commit message opens without problem, it's only upon `C-c C-c` that I got problems.
Gauthier
Maybe egg tries to spawn an editor when I press `C-c C-c`, and the editor detaches? I guess that is what you suggest. In that case, how can I know what editor egg/git is trying to start, and how to prevent that?
Gauthier
@Gauthier: that is what I suspect, but my emacs experience is rather limited and I have no precise "next steps" to add at this point.
VonC
+1  A: 

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.

Gauthier
apparently, emacs does not take the windows' path into account. It has to be in the `exec-path`, my bad. http://www.emacswiki.org/emacs/ExecPath
Gauthier
A: 

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.

Kalle