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 ()
|
(defun magit-log-edit-commit ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(magit-log-edit-cleanup)
|
(let* ((fields (magit-log-edit-get-fields))
|
||||||
(if (> (buffer-size) 0)
|
(amend (equal (cdr (assq 'amend fields)) "yes"))
|
||||||
(write-region (point-min) (point-max) ".git/magit-log")
|
(author (cdr (assq 'author fields))))
|
||||||
(write-region "(Empty description)" nil ".git/magit-log"))
|
(magit-log-edit-set-fields nil)
|
||||||
(erase-buffer)
|
(magit-log-edit-cleanup)
|
||||||
(magit-run "git" "commit" "-F" ".git/magit-log")
|
(if (> (buffer-size) 0)
|
||||||
(bury-buffer)
|
(write-region (point-min) (point-max) ".git/magit-log")
|
||||||
(when magit-pre-log-edit-window-configuration
|
(write-region "(Empty description)" nil ".git/magit-log"))
|
||||||
(set-window-configuration magit-pre-log-edit-window-configuration)
|
(erase-buffer)
|
||||||
(setq magit-pre-log-edit-window-configuration nil)))
|
(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 ()
|
(defun magit-log-edit-toggle-amending ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((fields (magit-log-edit-get-fields))
|
(let* ((fields (magit-log-edit-get-fields))
|
||||||
(cell (assq 'amend fields)))
|
(cell (assq 'amend fields)))
|
||||||
(if cell
|
(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))
|
(setq fields (acons 'amend "yes" fields))
|
||||||
(magit-log-edit-append
|
(magit-log-edit-append
|
||||||
(magit-format-commit "HEAD" "%s%n%n%b")))
|
(magit-format-commit "HEAD" "%s%n%n%b")))
|
||||||
|
|
Loading…
Add table
Reference in a new issue