It is possible to configure how a buffer opens (in the same frame/window or a different frame/window) using display-buffer-alist. Refer to the references below to learn more about this variable.
Solution
We need to tell emacs to always open buffers ending with COMMIT_EDITMSG in a window but not in the same (*magit ..*) window.
Add the following snippet to the init.el after (require 'magit) to specify this action.
(add-to-list 'display-buffer-alist
'(".*COMMIT_EDITMSG". ((display-buffer-pop-up-window) .
((inhibit-same-window . t)))))
Breakdown of the solution
display-buffer-alist is an alist that calls a FUNCTION (or a list of functions) with ALIST parameters when a CONDITION is true. The display-buffer-alist can be represented as,
'(CONDITION . (FUNCTION . ALIST))
- Here
CONDITION is that the buffer name ends with COMMIT_EDITMSG and that is represented by ".*COMMIT_EDITMSG".
- The
FUNCTION to call is display-buffer-pop-up-window as we want to create a window for this buffer. Instead of specifying the function by itself it's put in as a list of a single function (display-buffer-pop-up-window)so that more functions can be easily added to the list if needed in future.
- The
ALIST contains (inhibit-same-window . t) as we don't want this buffer to open in the same window.
References