summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-09-12 01:35:37 -0400
committerKyle Meyer <kyle@kyleam.com>2015-09-12 01:35:37 -0400
commit37b78790bdd917ce58ee6262d4122b96e12e928b (patch)
tree948d9a56eaf01d9d99c70dfeffa8349b8bd33281
parent040a3f0f1065b6e3f8000521ce7c448dfc6537c7 (diff)
downloademacs.d-37b78790bdd917ce58ee6262d4122b96e12e928b.tar.gz
magit-shorten-hash-at-point: Don't ignore numeric prefix
-rw-r--r--lisp/init-git.el7
1 files changed, 3 insertions, 4 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index 0514cfd..5d94c46 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -343,8 +343,8 @@ command will still offer the staged files)."
(completing-read "Staged file: " files nil t)))))
(insert (if no-directory (file-name-nondirectory file) file)))))
-(defun km/magit-shorten-hash (hash)
- (magit-rev-parse (format "--short=%s" (magit-abbrev-length)) hash))
+(defun km/magit-shorten-hash (hash &optional n)
+ (magit-rev-parse (format "--short=%s" (or n (magit-abbrev-length))) hash))
(defun km/magit-shorten-hash-at-point (&optional n)
"Shorten hash at point to N characters.
@@ -371,8 +371,7 @@ argument."
(hash (match-string 0)))
(when (< hash-len n)
(user-error "Desired hash length is greater than current"))
- (replace-match (or (km/magit-shorten-hash hash)
- (substring hash 0 n))
+ (replace-match (km/magit-shorten-hash hash n)
'fixedcase)
(when (< offset n)
(skip-chars-backward "A-z0-9")