summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-12-09 22:09:00 -0500
committerKyle Meyer <kyle@kyleam.com>2016-12-09 22:09:00 -0500
commitd92771c8a3373ca48c9976a94838b280e330093a (patch)
tree9f56c8df0edac1dadfda19a9233b2f89d2c28254
parent99c55ae7e1129a352d6d4db1a36f1c6eba3300f9 (diff)
downloademacs.d-d92771c8a3373ca48c9976a94838b280e330093a.tar.gz
Add magit-update-or-auto-commit command
-rw-r--r--init.el4
-rw-r--r--lisp/km-magit.el12
2 files changed, 14 insertions, 2 deletions
diff --git a/init.el b/init.el
index df8c174..38c345d 100644
--- a/init.el
+++ b/init.el
@@ -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.