tags:

views:

532

answers:

3

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

A: 

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 of mate 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 the mate 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.

mipadi
Thanks. I already posted to the TextMate mailing list pointing at this question.
Glyn Normington
Readers please note: this answer doesn't really answer the question, so please feel free to add a full answer!
Glyn Normington
A: 

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.

Glyn Normington
A: 

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.

extempore