summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-09-03 00:55:52 -0400
committerKyle Meyer <kyle@kyleam.com>2015-09-03 00:56:42 -0400
commitd943d5ea75b3434b1fb5c82790fc2c6dc0cf6bb0 (patch)
tree74295be3a089050be7deae37270b595cdc17f8ad
parentf9ab4a692f7abb6b56f49272091bec387eaee57b (diff)
downloademacs.d-d943d5ea75b3434b1fb5c82790fc2c6dc0cf6bb0.tar.gz
Add magit-commit-wip-with-file command
-rw-r--r--lisp/init-git.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index 9a803d2..638f591 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -82,6 +82,22 @@ CHOOSE-PROJECT is non-nil, prompt for the project name."
(t
(message "No changes to %s" file)))))
+(defun km/magit-commit-wip-with-file ()
+ "Make a WIP commit for the current file.
+Unlike `magit-wip-*' commands, this commit is made to the current
+branch."
+ (interactive)
+ (let ((file (or (buffer-file-name (buffer-base-buffer))
+ (user-error "Not visiting file"))))
+ (cond ((magit-anything-staged-p)
+ (user-error "There are already staged changes"))
+ ((member (magit-file-relative-name file) (magit-modified-files))
+ (magit-stage-file file)
+ (magit-run-git "commit" (format "--message=WIP %s"
+ (magit-file-relative-name file))))
+ (t
+ (message "No changes to %s" file)))))
+
(defun km/magit-ff-merge-upstream ()
"Perform fast-forward merge of upstream branch.
\n(git merge --no-edit --ff-only <upstream>)"