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:
parent
1e7a9e3d66
commit
2a5da19c7f
1 changed files with 17 additions and 12 deletions
27
magit.el
27
magit.el
|
@ -1089,23 +1089,28 @@ Please see the manual for a complete description of Magit.
|
|||
|
||||
(defun magit-log-edit-commit ()
|
||||
(interactive)
|
||||
(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")
|
||||
(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)))
|
||||
(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)
|
||||
(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))))
|
||||
|
||||
(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")))
|
||||
|
|
Loading…
Add table
Reference in a new issue