summaryrefslogtreecommitdiff
path: root/lisp/km-magit.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/km-magit.el')
-rw-r--r--lisp/km-magit.el34
1 files changed, 18 insertions, 16 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index 3dd433c..204bddb 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -50,19 +50,21 @@ a proper commit."
(interactive)
(magit-run-git "commit" "--all" "--message=auto"))
-(defun km/magit-update-or-auto-commit (&optional no-directory)
+(defun km/magit-update-or-auto-commit (&optional full-name)
(interactive "P")
(let ((files (delete-dups (nconc (magit-unstaged-files)
(magit-staged-files)))))
(cl-case (length files)
(0 (user-error "No tracked files with changes"))
(1
- (magit-run-git "commit" "--all" "--message"
- (concat (funcall (if no-directory
- #'file-name-nondirectory
- #'identity)
- (car files))
- ": Update")))
+ (let ((file (car files)))
+ (magit-run-git "commit" "--all" "--message"
+ (concat (funcall (if full-name
+ #'identity
+ #'file-name-nondirectory)
+ file)
+ (and (magit-rev-verify (concat "HEAD:" file))
+ ": Update")))))
(t
(km/magit-auto-commit)))))
@@ -255,7 +257,7 @@ argument SUFFIX, prompt for a suffix to use instead of
(list
(magit-completing-read
"Branch to archive" (magit-list-refnames "refs/heads")
- nil 'require nil nil
+ nil 'require-match nil nil
(or (magit-branch-at-point) (magit-get-previous-branch)))))))
(setq branches
(mapcar (lambda (branch)
@@ -320,7 +322,7 @@ argument SUFFIX, prompt for a suffix to use instead of
(interactive
(list (magit-completing-read
"Delete set with member" (magit-list-refnames "refs/heads")
- nil 'require nil nil
+ nil 'require-match nil nil
(or (magit-branch-at-point) (magit-get-previous-branch)))))
(km/magit-branch--set-action
"Delete"
@@ -332,7 +334,7 @@ argument SUFFIX, prompt for a suffix to use instead of
(interactive
(list (magit-completing-read
"Archive set with member" (magit-list-refnames "refs/heads")
- nil 'require nil nil
+ nil 'require-match nil nil
(or (magit-branch-at-point) (magit-get-previous-branch)))))
(km/magit-branch--set-action
"Archive"
@@ -467,13 +469,13 @@ N defaults to 20."
(1 (car files))
(t (magit-completing-read "File" files nil t))))))
-(defun km/magit-insert-staged-file (&optional no-directory)
+(defun km/magit-insert-staged-file (&optional full-name)
"Select a staged file to insert.
This is useful for referring to file names in commit messages.
By default, the path for the file name is relative to the top
directory of the repository. Remove the directory component from
-the file name if NO-DIRECTORY is non-nil.
+the file name unless FULL-NAME is non-nil.
If there are no staged files, look instead at files that changed
in HEAD. These rules will usually offer the files of interest
@@ -489,7 +491,7 @@ command will still offer the staged files)."
(0 (error "No files found"))
(t
(completing-read "Staged file: " files nil t)))))
- (insert (if no-directory (file-name-nondirectory file) file)))))
+ (insert (if full-name file (file-name-nondirectory file))))))
(defun km/magit-shorten-hash (hash &optional n)
(magit-rev-parse (format "--short=%s" (or n (magit-abbrev-length))) hash))
@@ -546,7 +548,7 @@ argument."
(defun km/magit-rev-ancestor-p (rev-a rev-b)
"Report whether REV-A is an ancestor of REV-B."
(interactive
- (let* ((rev-a (magit-read-branch-or-commit "Ancestor candidate")))
+ (let ((rev-a (magit-read-branch-or-commit "Ancestor candidate")))
(list rev-a (magit-read-other-branch-or-commit
(format "Is %s an ancestor of" rev-a)
rev-a))))
@@ -1141,8 +1143,8 @@ function."
;; This always converts to commits IDs. It could try to map
;; refnames to the appropriate GitHub link (including remotes
;; to forks), but I don't have much need for it at the moment.
- (let ((rev1 (magit-rev-parse (match-string 1 magit-buffer-range)))
- (rev2 (magit-rev-parse (match-string 3 magit-buffer-range))))
+ (let ((rev1 (magit-commit-p (match-string 1 magit-buffer-range)))
+ (rev2 (magit-commit-p (match-string 3 magit-buffer-range))))
(format "%s/compare/%s...%s"
(or (km/magit-github-url) "")
rev1 rev2)))))