@matheusbsbs / matheus-bagliano / commits / ef5133df7c
Fork 0

git.el: Properly handle merge commits in git-amend-commit.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

Alexandre Julliard committed Aug 2, 2008 at 18:05 UTC ef5133df7c9d0304ce2fc437abc74c220f49dabd
1 file changed +9 -8
contrib/emacs/git.el
+9 -8
@@ -1235,11 +1235,10 @@ Return the list of files that haven't been handled."
1235 (goto-char (point-max))
1236 (insert sign-off "\n"))))
1237
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)
1239 "Setup the log buffer for a commit."
1240 (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)
1242 (committer-name (git-get-committer-name))
1243 (committer-email (git-get-committer-email))
1244 (sign-off git-append-signed-off-by))
@@ -1294,7 +1293,7 @@ Return the list of files that haven't been handled."
1293 (goto-char (point-min))
1294 (when (re-search-forward "^Date: \\(.*\\)$" nil t)
1295 (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))
1297 (if (boundp 'log-edit-diff-function)
1298 (log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files)
1299 (log-edit-diff-function . git-log-edit-diff)) buffer)
@@ -1305,11 +1304,13 @@ Return the list of files that haven't been handled."
1304
1305 (defun git-setup-commit-buffer (commit)
1306 "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)
1308 (with-temp-buffer
1309 (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)
1311 (goto-char (point-min))
1312 + (when (re-search-forward "^Merge: *\\(.*\\)$" nil t)
1313 + (setq parents (cdr (split-string (match-string 1) " +"))))
1314 (when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
1315 (setq author-name (match-string 1))
1316 (setq author-email (match-string 2)))
@@ -1321,14 +1322,14 @@ Return the list of files that haven't been handled."
1322 (setq subject (pop msg))
1323 (while (and msg (zerop (length (car msg))) (pop msg)))))
1324 (git-setup-log-buffer (get-buffer-create "*git-commit*")
1324 - author-name author-email subject date
1325 + parents author-name author-email subject date
1326 (mapconcat #'identity msg "\n"))))
1327
1328 (defun git-get-commit-files (commit)
1329 "Retrieve the list of files modified by COMMIT."
1330 (let (files)
1331 (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)
1333 (goto-char (point-min))
1334 (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
1335 (push (match-string 1) files)))