Commit amending.

* magit.el (magit-log-edit-commit): Look at 'amend' field and pass
"--amend" to git commit when true.
This commit is contained in:
Marius Vollmer 2008-08-31 18:18:46 +03:00
parent 1e7a9e3d66
commit 2a5da19c7f

View file

@ -1089,23 +1089,28 @@ Please see the manual for a complete description of Magit.
(defun magit-log-edit-commit ()
(interactive)
(let* ((fields (magit-log-edit-get-fields))
(amend (equal (cdr (assq 'amend fields)) "yes"))
(author (cdr (assq 'author fields))))
(magit-log-edit-set-fields nil)
(magit-log-edit-cleanup)
(if (> (buffer-size) 0)
(write-region (point-min) (point-max) ".git/magit-log")
(write-region "(Empty description)" nil ".git/magit-log"))
(erase-buffer)
(magit-run "git" "commit" "-F" ".git/magit-log")
(apply #'magit-run "git" "commit" "-F" ".git/magit-log"
(if amend '("--amend") '()))
(bury-buffer)
(when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil)))
(setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-toggle-amending ()
(interactive)
(let* ((fields (magit-log-edit-get-fields))
(cell (assq 'amend fields)))
(if cell
(rplacd cell (if (equal (cdr cell) "no") "yes" "no"))
(rplacd cell (if (equal (cdr cell) "yes") "no" "yes"))
(setq fields (acons 'amend "yes" fields))
(magit-log-edit-append
(magit-format-commit "HEAD" "%s%n%n%b")))