mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 04:21:24 +00:00
vc--subject-to-file-name: Fix over-greedy regex (bug#81017)
* lisp/vc/vc.el (vc--subject-to-file-name): Make the prefix regex less greedy, ensure the result has no text properties, improve the docstring (bug#81017).
This commit is contained in:
parent
05f89d711d
commit
2d915236dc
1 changed files with 10 additions and 6 deletions
|
|
@ -5393,15 +5393,19 @@ of the current file."
|
|||
(vc-working-revision file)))))
|
||||
|
||||
(defun vc--subject-to-file-name (subject)
|
||||
"Generate a file name for a patch with subject line SUBJECT."
|
||||
"Generate a file name for a patch with subject line SUBJECT.
|
||||
|
||||
The resulting filename is similar to the names generated by \"git
|
||||
format-patch\", but without the leading patch sequence number \"0001-\".
|
||||
Any leading \"[PATCH 1/1]\" style strings, and any text properties are
|
||||
removed from SUBJECT prior to conversion."
|
||||
(let* ((stripped
|
||||
(replace-regexp-in-string "\\`\\[.*PATCH.*\\]\\s-*" ""
|
||||
(replace-regexp-in-string "\\`\\[[^][]*PATCH[^][]*]\\s-*" ""
|
||||
subject))
|
||||
(truncated (if (length> stripped 50)
|
||||
(substring stripped 0 50)
|
||||
stripped)))
|
||||
(truncated (substring-no-properties stripped
|
||||
0 (min (length stripped) 50))))
|
||||
(concat
|
||||
(string-trim (replace-regexp-in-string "\\W" "-" truncated)
|
||||
(string-trim (replace-regexp-in-string "\\W+" "-" truncated)
|
||||
"-+" "-+")
|
||||
".patch")))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue