summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-10-18 00:29:08 -0400
committerKyle Meyer <kyle@kyleam.com>2014-10-18 00:29:08 -0400
commit71f099b9728fdd2f0507ba3e7471ea2deb2dac04 (patch)
treef4b1abfe7b8e3df513ba100e4020c28c4137ec3b
parente4985555a4d5e381e626e0e79cc6115a7dbc7ca9 (diff)
downloademacs.d-71f099b9728fdd2f0507ba3e7471ea2deb2dac04.tar.gz
Add command magit-stage-file-intent
-rw-r--r--lisp/init-git.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index d78655d..3c84931 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -40,6 +40,24 @@ This is useful for commit IDs in files and log messages."
'(lambda () (magit-show-commit it))))
(projectile-switch-project))))
+(defun km/magit-stage-file-intent (file)
+ "Stage FILE but not its content.
+With a prefix argument or when there is no file at point ask for
+the file to be staged. Otherwise stage the file at point without
+requiring confirmation.
+\n(git add -N FILE)"
+ ;; Modified from `magit-stage-file'.
+ (interactive
+ (let* ((atpoint (magit-section-when (file)))
+ (current (magit-file-relative-name))
+ (choices (magit-untracked-files))
+ (default (car (member (or atpoint current) choices))))
+ (list (if (or current-prefix-arg (not default))
+ (magit-completing-read "Stage file" choices
+ nil t nil nil default)
+ default))))
+ (magit-run-git "add" "-N" file))
+
(defun km/magit-push-all ()
"Push all branches."
(interactive)
@@ -115,6 +133,8 @@ START-POINT set to the current branch.
;; my binding for `km/zsh-ansi-term-other-window'.
(define-key magit-mode-map (kbd "C-x 4 a") nil)
+ (define-key magit-mode-map "N" 'km/magit-stage-file-intent)
+
(magit-define-popup-action 'magit-commit-popup
?u "Auto commit" 'km/magit-auto-commit)
(magit-define-popup-action 'magit-push-popup