aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc
diff options
context:
space:
mode:
authorPhilip Kaludercic2022-10-15 17:38:30 +0200
committerPhilip Kaludercic2022-10-15 17:38:30 +0200
commit01e45efcd44e92dd259283df0e62653c7c20e9cc (patch)
tree552c1a6ce7d52b897cf5f089d6c589921efbe9bd /lisp/vc
parent982c0e6c15535defcf6ac3c4d4169708c60efc18 (diff)
parent5933055a3e7387b0095f0df7876a208ab15f4f45 (diff)
downloademacs-01e45efcd44e92dd259283df0e62653c7c20e9cc.tar.gz
emacs-01e45efcd44e92dd259283df0e62653c7c20e9cc.zip
Merge branch 'master' into feature/package+vc
Diffstat (limited to 'lisp/vc')
-rw-r--r--lisp/vc/vc-git.el45
-rw-r--r--lisp/vc/vc.el46
2 files changed, 59 insertions, 32 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8ffe41758ed..d63d755a287 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -373,8 +373,9 @@ in the order given by `git status'."
373 373
374(defun vc-git-working-revision (_file) 374(defun vc-git-working-revision (_file)
375 "Git-specific version of `vc-working-revision'." 375 "Git-specific version of `vc-working-revision'."
376 (let (process-file-side-effects) 376 (let* ((process-file-side-effects nil)
377 (vc-git--rev-parse "HEAD"))) 377 (commit (vc-git--rev-parse "HEAD" t)))
378 (or (vc-git-symbolic-commit commit) commit)))
378 379
379(defun vc-git--symbolic-ref (file) 380(defun vc-git--symbolic-ref (file)
380 (or 381 (or
@@ -1638,7 +1639,7 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
1638 (start-point (when branchp (vc-read-revision 1639 (start-point (when branchp (vc-read-revision
1639 (format-prompt "Start point" 1640 (format-prompt "Start point"
1640 (car (vc-git-branches))) 1641 (car (vc-git-branches)))
1641 (list dir) 'Git)))) 1642 (list dir) 'Git (car (vc-git-branches))))))
1642 (and (or (zerop (vc-git-command nil t nil "update-index" "--refresh")) 1643 (and (or (zerop (vc-git-command nil t nil "update-index" "--refresh"))
1643 (y-or-n-p "Modified files exist. Proceed? ") 1644 (y-or-n-p "Modified files exist. Proceed? ")
1644 (user-error (format "Can't create %s with modified files" 1645 (user-error (format "Can't create %s with modified files"
@@ -1677,11 +1678,15 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
1677 ;; does not (and cannot) quote. 1678 ;; does not (and cannot) quote.
1678 (vc-git--rev-parse (concat rev "~1")))) 1679 (vc-git--rev-parse (concat rev "~1"))))
1679 1680
1680(defun vc-git--rev-parse (rev) 1681(defun vc-git--rev-parse (rev &optional short)
1681 (with-temp-buffer 1682 (with-temp-buffer
1682 (and 1683 (and
1683 (vc-git--out-ok "rev-parse" rev) 1684 (if short
1684 (buffer-substring-no-properties (point-min) (+ (point-min) 40))))) 1685 (vc-git--out-ok "rev-parse" "--short" rev)
1686 (vc-git--out-ok "rev-parse" rev))
1687 (string-trim-right
1688 (buffer-substring-no-properties (point-min) (min (+ (point-min) 40)
1689 (point-max)))))))
1685 1690
1686(defun vc-git-next-revision (file rev) 1691(defun vc-git-next-revision (file rev)
1687 "Git-specific version of `vc-next-revision'." 1692 "Git-specific version of `vc-next-revision'."
@@ -2028,19 +2033,23 @@ FILE can be nil."
2028 (setq ok nil)))))) 2033 (setq ok nil))))))
2029 (and ok str))) 2034 (and ok str)))
2030 2035
2031(defun vc-git-symbolic-commit (commit) 2036(defun vc-git-symbolic-commit (commit &optional force)
2032 "Translate COMMIT string into symbolic form. 2037 "Translate revision string of COMMIT to a symbolic form.
2033Returns nil if not possible." 2038If the optional argument FORCE is non-nil, the returned value is
2039allowed to include revision specifications like \"master~8\"
2040\(the 8th parent of the commit currently pointed to by the master
2041branch), otherwise such revision specifications are rejected, and
2042the function returns nil."
2034 (and commit 2043 (and commit
2035 (let ((name (with-temp-buffer 2044 (with-temp-buffer
2036 (and 2045 (and
2037 (vc-git--out-ok "name-rev" "--name-only" commit) 2046 (vc-git--out-ok "name-rev" "--no-undefined" "--name-only" commit)
2038 (goto-char (point-min)) 2047 (goto-char (point-min))
2039 (= (forward-line 2) 1) 2048 (or force (not (looking-at "^.*[~^].*$" t)))
2040 (bolp) 2049 (= (forward-line 2) 1)
2041 (buffer-substring-no-properties (point-min) 2050 (bolp)
2042 (1- (point-max))))))) 2051 (buffer-substring-no-properties (point-min)
2043 (and name (not (string= name "undefined")) name)))) 2052 (1- (point-max)))))))
2044 2053
2045(defvar-keymap vc-dir-git-mode-map 2054(defvar-keymap vc-dir-git-mode-map
2046 "z c" #'vc-git-stash 2055 "z c" #'vc-git-stash
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 14b149310c4..49bb7a27aad 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1926,6 +1926,13 @@ Return t if the buffer had changes, nil otherwise."
1926 "History for `vc-read-revision'.") 1926 "History for `vc-read-revision'.")
1927 1927
1928(defun vc-read-revision (prompt &optional files backend default initial-input multiple) 1928(defun vc-read-revision (prompt &optional files backend default initial-input multiple)
1929 "Query the user for a revision using PROMPT.
1930All subsequent arguments are optional. FILES may specify a file
1931set to restrict the revisions to. BACKEND is a VC backend as
1932listed in `vc-handled-backends'. DEFAULT and INITIAL-INPUT are
1933handled as defined by `completing-read'. If MULTIPLE is non-nil,
1934the user may be prompted for multiple revisions. If possible
1935this means that `completing-read-multiple' will be used."
1929 (cond 1936 (cond
1930 ((null files) 1937 ((null files)
1931 (let ((vc-fileset (vc-deduce-fileset t))) ;FIXME: why t? --Stef 1938 (let ((vc-fileset (vc-deduce-fileset t))) ;FIXME: why t? --Stef
@@ -1947,6 +1954,10 @@ Return t if the buffer had changes, nil otherwise."
1947 answer))))) 1954 answer)))))
1948 1955
1949(defun vc-read-multiple-revisions (prompt &optional files backend default initial-input) 1956(defun vc-read-multiple-revisions (prompt &optional files backend default initial-input)
1957 "Query the user for multiple revisions.
1958This is equivalent to invoking `vc-read-revision' with t for
1959MULTIPLE. The arguments PROMPT, FILES, BACKEND, DEFAULT and
1960INITIAL-INPUT are passed on to `vc-read-revision' directly."
1950 (vc-read-revision prompt files backend default initial-input t)) 1961 (vc-read-revision prompt files backend default initial-input t))
1951 1962
1952(defun vc-diff-build-argument-list-internal (&optional fileset) 1963(defun vc-diff-build-argument-list-internal (&optional fileset)
@@ -3287,10 +3298,11 @@ immediately after this one."
3287 (apply #'vc-user-edit-command (apply old args)))))) 3298 (apply #'vc-user-edit-command (apply old args))))))
3288 3299
3289(defcustom vc-prepare-patches-separately t 3300(defcustom vc-prepare-patches-separately t
3290 "Non-nil means that `vc-prepare-patch' creates a single message. 3301 "Whether `vc-prepare-patch' should generate a separate message for each patch.
3291A single message is created by attaching all patches to the body 3302If nil, `vc-prepare-patch' creates a single email message by attaching
3292of a single message. If nil, each patch will be sent out in a 3303all the patches to the body of that message. If non-nil, each patch
3293separate message, which will be prepared sequentially." 3304will be sent out in a separate message, and the messages will be
3305prepared sequentially."
3294 :type 'boolean 3306 :type 'boolean
3295 :safe #'booleanp 3307 :safe #'booleanp
3296 :version "29.1") 3308 :version "29.1")
@@ -3308,7 +3320,7 @@ If nil, no default will be used. This option may be set locally."
3308 (buffer &optional type description disposition)) 3320 (buffer &optional type description disposition))
3309(declare-function log-view-get-marked "log-view" ()) 3321(declare-function log-view-get-marked "log-view" ())
3310 3322
3311(defun vc-default-prepare-patch (rev) 3323(defun vc-default-prepare-patch (_backend rev)
3312 (let ((backend (vc-backend buffer-file-name))) 3324 (let ((backend (vc-backend buffer-file-name)))
3313 (with-current-buffer (generate-new-buffer " *vc-default-prepare-patch*") 3325 (with-current-buffer (generate-new-buffer " *vc-default-prepare-patch*")
3314 (vc-diff-internal 3326 (vc-diff-internal
@@ -3325,15 +3337,21 @@ If nil, no default will be used. This option may be set locally."
3325;;;###autoload 3337;;;###autoload
3326(defun vc-prepare-patch (addressee subject revisions) 3338(defun vc-prepare-patch (addressee subject revisions)
3327 "Compose an Email sending patches for REVISIONS to ADDRESSEE. 3339 "Compose an Email sending patches for REVISIONS to ADDRESSEE.
3328If `vc-prepare-patches-separately' is non-nil, SUBJECT will be used 3340If `vc-prepare-patches-separately' is nil, SUBJECT will be used
3329as the default subject for the message. Otherwise a separate 3341as the default subject for the message (and it will be prompted
3330message will be composed for each revision. 3342for when called interactively). Otherwise a separate message
3343will be composed for each revision, with SUBJECT derived from the
3344invidividual commits.
3331 3345
3332When invoked interactively in a Log View buffer with marked 3346When invoked interactively in a Log View buffer with marked
3333revisions, these revisions will be used." 3347revisions, those revisions will be used."
3334 (interactive 3348 (interactive
3335 (let ((revs (or (log-view-get-marked) 3349 (let ((revs (vc-read-multiple-revisions
3336 (vc-read-multiple-revisions "Revisions: "))) 3350 "Revisions: " nil nil nil
3351 (or (and-let* ((revs (log-view-get-marked)))
3352 (mapconcat #'identity revs ","))
3353 (and-let* ((file (buffer-file-name)))
3354 (vc-working-revision file)))))
3337 to) 3355 to)
3338 (require 'message) 3356 (require 'message)
3339 (while (null (setq to (completing-read-multiple 3357 (while (null (setq to (completing-read-multiple
@@ -3357,7 +3375,8 @@ revisions, these revisions will be used."
3357 'prepare-patch rev)) 3375 'prepare-patch rev))
3358 revisions))) 3376 revisions)))
3359 (if vc-prepare-patches-separately 3377 (if vc-prepare-patches-separately
3360 (dolist (patch patches) 3378 (dolist (patch (reverse patches)
3379 (message "Prepared %d patches..." (length patches)))
3361 (compose-mail addressee 3380 (compose-mail addressee
3362 (plist-get patch :subject) 3381 (plist-get patch :subject)
3363 nil nil nil nil 3382 nil nil nil nil
@@ -3368,8 +3387,7 @@ revisions, these revisions will be used."
3368 (insert-buffer-substring 3387 (insert-buffer-substring
3369 (plist-get patch :buffer) 3388 (plist-get patch :buffer)
3370 (plist-get patch :body-start) 3389 (plist-get patch :body-start)
3371 (plist-get patch :body-end))) 3390 (plist-get patch :body-end))))
3372 (recursive-edit))
3373 (compose-mail addressee subject nil nil nil nil 3391 (compose-mail addressee subject nil nil nil nil
3374 (mapcar 3392 (mapcar
3375 (lambda (p) 3393 (lambda (p)