branch: elpa/git-commit
commit 9319403ce6e13040ddb01551493bd12a34038491
Author: Kyle Meyer <[email protected]>
Commit: Kyle Meyer <[email protected]>
Don't hard code null objects at SHA-1 length
Two places hard code the null object at 40 characters. Allow 40
characters or more to be compatible with Git's experimental SHA-256
support.
Another approach would be to keep using `equal' and determine the
appropriate length by calling 'git rev-parse --show-object-format'
(plus some compatibility logic since that's not available until 2.25).
The more liberal "40 or more zeros" condition seems good enough for
these spots, though.
Re: #4516
---
lisp/magit-blame.el | 2 +-
lisp/magit-extras.el | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index 357e112fd3..eacaa726b5 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -638,7 +638,7 @@ modes is toggled, then this mode also gets toggled
automatically.
(defun magit-blame--format-string-1 (rev revinfo format face)
(let ((str
- (if (equal rev "0000000000000000000000000000000000000000")
+ (if (string-match-p "\\`0\\{40,\\}\\'" rev)
(propertize (concat (if (string-prefix-p "\s" format) "\s" "")
"Not Yet Committed"
(if (string-suffix-p "\n" format) "\n" ""))
diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el
index a7966d1a9e..95aaf966b9 100644
--- a/lisp/magit-extras.el
+++ b/lisp/magit-extras.el
@@ -377,7 +377,7 @@ points at it) otherwise."
(interactive (list (and current-prefix-arg 'removal)))
(let* ((chunk (magit-current-blame-chunk (or type 'addition)))
(rev (oref chunk orig-rev)))
- (if (equal rev "0000000000000000000000000000000000000000")
+ (if (string-match-p "\\`0\\{40,\\}\\'" rev)
(message "This line has not been committed yet")
(let ((rebase (magit-rev-ancestor-p rev "HEAD"))
(file (expand-file-name (oref chunk orig-file)