summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-09-15 00:28:17 -0400
committerKyle Meyer <kyle@kyleam.com>2015-09-15 00:28:17 -0400
commit9a5adfd37e66e1e6fdb3473c21d4b7c86aeaed3c (patch)
tree0b4f019cc9ef9b6d1b0b15d393a3e7279f17985d
parent78872e800636b43c4b6285882ef96b53ce298929 (diff)
downloademacs.d-9a5adfd37e66e1e6fdb3473c21d4b7c86aeaed3c.tar.gz
magit-commit-{extend,wip}-with-file: Support status buffer
-rw-r--r--lisp/init-git.el19
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index b43ee54..0b13be2 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -70,12 +70,12 @@ CHOOSE-PROJECT is non-nil, prompt for the project name."
(defun km/magit-commit-extend-with-file ()
"Extend last commit with changes in the current file."
(interactive)
- (let ((file (or (buffer-file-name (buffer-base-buffer))
- (user-error "Not visiting file"))))
+ (let ((file (or (magit-current-file)
+ (user-error "No current 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)
+ ((member file (magit-modified-files))
+ (magit-with-toplevel (magit-stage-file file))
(magit-commit-extend))
(t
(message "No changes to %s" file)))))
@@ -85,14 +85,13 @@ CHOOSE-PROJECT is non-nil, prompt for the project name."
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"))))
+ (let ((file (or (magit-current-file)
+ (user-error "No current 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))))
+ ((member file (magit-modified-files))
+ (magit-with-toplevel (magit-stage-file file))
+ (magit-run-git "commit" (concat "--message=WIP " file)))
(t
(message "No changes to %s" file)))))