Skip to content

Commit ef5133d

Browse files
committed
git.el: Properly handle merge commits in git-amend-commit.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
1 parent 6fb2042 commit ef5133d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

contrib/emacs/git.el

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,11 +1235,10 @@ Return the list of files that haven't been handled."
12351235
(goto-char (point-max))
12361236
(insert sign-off "\n"))))
12371237

1238-
(defun git-setup-log-buffer (buffer &optional author-name author-email subject date msg)
1238+
(defun git-setup-log-buffer (buffer &optional merge-heads author-name author-email subject date msg)
12391239
"Setup the log buffer for a commit."
12401240
(unless git-status (error "Not in git-status buffer."))
1241-
(let ((merge-heads (git-get-merge-heads))
1242-
(dir default-directory)
1241+
(let ((dir default-directory)
12431242
(committer-name (git-get-committer-name))
12441243
(committer-email (git-get-committer-email))
12451244
(sign-off git-append-signed-off-by))
@@ -1294,7 +1293,7 @@ Return the list of files that haven't been handled."
12941293
(goto-char (point-min))
12951294
(when (re-search-forward "^Date: \\(.*\\)$" nil t)
12961295
(setq date (match-string 1)))))
1297-
(git-setup-log-buffer buffer author-name author-email subject date))
1296+
(git-setup-log-buffer buffer (git-get-merge-heads) author-name author-email subject date))
12981297
(if (boundp 'log-edit-diff-function)
12991298
(log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files)
13001299
(log-edit-diff-function . git-log-edit-diff)) buffer)
@@ -1305,11 +1304,13 @@ Return the list of files that haven't been handled."
13051304

13061305
(defun git-setup-commit-buffer (commit)
13071306
"Setup the commit buffer with the contents of COMMIT."
1308-
(let (author-name author-email subject date msg)
1307+
(let (parents author-name author-email subject date msg)
13091308
(with-temp-buffer
13101309
(let ((coding-system (git-get-logoutput-coding-system)))
1311-
(git-call-process t "log" "-1" "--pretty=medium" commit)
1310+
(git-call-process t "log" "-1" "--pretty=medium" "--abbrev=40" commit)
13121311
(goto-char (point-min))
1312+
(when (re-search-forward "^Merge: *\\(.*\\)$" nil t)
1313+
(setq parents (cdr (split-string (match-string 1) " +"))))
13131314
(when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
13141315
(setq author-name (match-string 1))
13151316
(setq author-email (match-string 2)))
@@ -1321,14 +1322,14 @@ Return the list of files that haven't been handled."
13211322
(setq subject (pop msg))
13221323
(while (and msg (zerop (length (car msg))) (pop msg)))))
13231324
(git-setup-log-buffer (get-buffer-create "*git-commit*")
1324-
author-name author-email subject date
1325+
parents author-name author-email subject date
13251326
(mapconcat #'identity msg "\n"))))
13261327

13271328
(defun git-get-commit-files (commit)
13281329
"Retrieve the list of files modified by COMMIT."
13291330
(let (files)
13301331
(with-temp-buffer
1331-
(git-call-process t "diff-tree" "-r" "-z" "--name-only" "--no-commit-id" commit)
1332+
(git-call-process t "diff-tree" "-m" "-r" "-z" "--name-only" "--no-commit-id" commit)
13321333
(goto-char (point-min))
13331334
(while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
13341335
(push (match-string 1) files)))

0 commit comments

Comments
 (0)