-1

I setup textmate to be my editor in git:

$ git config --list --global | grep editor
core.editor=mate

When I do commands like:

$ git commit --amend 

or

$ git rebase -i <hash>

The editor is opened as expected, but the it appears to be opened asynchronously, for when I look back at the command prompt I see this:

[mybranch 099f0ea] My new changes
 Date: Tue Jan 28 19:11:52 2020 -0800
 3 files changed, 5 insertions(+), 9 deletions(-)

The changes appear to have been committed even though I haven't saved any changes to the file in my editor. Also, saving any changes to the file in the editor have no effect. Its almost as if the editor was opened asynchronously.

Any ideas why this happens?

jersey bean
  • 3,321
  • 4
  • 28
  • 43
  • Did you already have the editor open when you executed that commit command? – Lasse V. Karlsen Jan 29 '20 at 18:59
  • There could be 2 causes: either the editor is already started and the new instance brings the existing instance in foreground and exits, or the program you configured as editor is not the real editor but just a bootstrap that launches the real editor and exits. – axiac Jan 29 '20 at 18:59
  • 2
    You need to call `mate` with the `-w` (wait) option. Otherwise, it is launched in the background and control returns immediately to `git`, which thinks you have closed your editor. Read https://macromates.com/manual/en/using_textmate_from_terminal for more details (and possibly a more complete command line). – larsks Jan 29 '20 at 19:00
  • 1
    The way git using an editor works is that git spawns the process for the editor, and then waits for that process to terminate. Some editors that allow for 1 instance talks to the existing instance to tell it open the new file, and then terminates, ie. temporarily there's two instances but the one git started terminates as soon as it has talked to the already open instance. That, or "mate" is a script or executable that spawns the real editor and then terminates. There could be command line options for mate to wait until the file is closed, like `--wait` or similar. – Lasse V. Karlsen Jan 29 '20 at 19:00

1 Answers1

1

In Terminal, say:

git config --global core.editor "mate -w"

(Source: https://help.github.com/en/github/using-git/associating-text-editors-with-git)

matt
  • 515,959
  • 87
  • 875
  • 1,141