diff options
-rw-r--r-- | init.el | 4 | ||||
-rw-r--r-- | lisp/km-magit.el | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -1014,7 +1014,7 @@ ("p" . km/magit-pin-file) ("r" . km/magit-find-recently-changed-file) ("t" . km/magit-describe) - ("u" . km/magit-auto-commit) + ("u" . km/magit-update-or-auto-commit) ("v" . km/magit-revfile-reset)) :config (bind-keys :map magit-mode-map @@ -1059,7 +1059,7 @@ ("m" . km/git-rebase-move-commit))) (magit-define-popup-action 'magit-commit-popup - ?u "Auto commit" #'km/magit-auto-commit) + ?u "Auto commit" #'km/magit-update-or-auto-commit) (magit-define-popup-action 'magit-push-popup ?a "Push all" #'km/magit-push-all) diff --git a/lisp/km-magit.el b/lisp/km-magit.el index 9b6c3cd..d4af9d3 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -46,6 +46,18 @@ a proper commit." (interactive) (magit-run-git "commit" "--all" "--message=auto")) +(defun km/magit-update-or-auto-commit () + (interactive) + (let ((files (delete-dups (nconc (magit-modified-files) + (magit-staged-files))))) + (cl-case (length files) + (0 (user-error "No tracked files with changes")) + (1 + (magit-run-git "commit" "--all" "--message" + (concat (car files) ": Update"))) + (t + (km/magit-auto-commit))))) + ;;;###autoload (defun km/magit-show-commit-at-point (&optional choose-project) "Show commit point. |