aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-10-20 21:02:07 +0300
committerEli Zaretskii2024-10-20 21:02:07 +0300
commit75fa0cc1ae2b53fe169fdcfef52bee6719eb38a7 (patch)
tree6cacbfc0cd3de090244b4f7568df19826e2e3422
parentd3975cc925a856c872016df734563ce0709f3efc (diff)
downloademacs-75fa0cc1ae2b53fe169fdcfef52bee6719eb38a7.tar.gz
emacs-75fa0cc1ae2b53fe169fdcfef52bee6719eb38a7.zip
; Fix last change.
* lisp/net/eww.el (eww--list-buffers-display-table) (eww-buffers-mode): Fix coding conventions.
-rw-r--r--lisp/net/eww.el6
-rw-r--r--lisp/vc/vc-git.el170
2 files changed, 145 insertions, 31 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 17ebccc9453..63ad4ae78b7 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -2617,7 +2617,7 @@ see)."
2617 (eww--list-buffers-display-table)) 2617 (eww--list-buffers-display-table))
2618 (pop-to-buffer "*eww buffers*")) 2618 (pop-to-buffer "*eww buffers*"))
2619 2619
2620(defun eww--list-buffers-display-table (&optional ignore-auto noconfirm) 2620(defun eww--list-buffers-display-table (&optional _ignore-auto _noconfirm)
2621 "Display a table with the list of eww buffers. 2621 "Display a table with the list of eww buffers.
2622Will remove all buffer contents first. The parameters IGNORE-AUTO and 2622Will remove all buffer contents first. The parameters IGNORE-AUTO and
2623NOCONFIRM are ignored, they are for compatibility with 2623NOCONFIRM are ignored, they are for compatibility with
@@ -2711,8 +2711,8 @@ The format of the data is (title url buffer), for use in of
2711 :interactive nil 2711 :interactive nil
2712 (buffer-disable-undo) 2712 (buffer-disable-undo)
2713 (setq truncate-lines t 2713 (setq truncate-lines t
2714 ;; this is set so that pressing "g" with point just below the 2714 ;; This is set so that pressing "g" with point just below the
2715 ;; table will still update the listing 2715 ;; table will still update the listing.
2716 revert-buffer-function #'eww--list-buffers-display-table)) 2716 revert-buffer-function #'eww--list-buffers-display-table))
2717 2717
2718;;; Desktop support 2718;;; Desktop support
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index f77bf0cc5ff..d2ada63f71e 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -252,6 +252,27 @@ included in the completions."
252 :type 'boolean 252 :type 'boolean
253 :version "28.1") 253 :version "28.1")
254 254
255;; The default is nil because only a VC user who also possesses a lot of
256;; Git-specific knowledge can know when it is okay to rewrite history,
257;; and we can't convey to a relatively Git-naïve user the potential
258;; risks in only the space of a minibuffer y/n prompt.
259(defcustom vc-git-allow-rewriting-history nil
260 "When non-nil, permit Git operations that may rewrite published history.
261
262Many Git commands can change your copy of published change history
263without warning. If this occurs, you won't be able to pull and push in
264the ordinary way until you take special action. See \"Recovering from
265Upstream Rebase\" in the Man page git-rebase(1).
266
267Normally, Emacs refuses to run Git commands that it thinks will rewrite
268published history. If you customize this variable to a non-nil value,
269Emacs will instead prompt you to confirm that you really want to perform
270the rewrite. A value of `no-ask' means to proceed with no prompting."
271 :type '(choice (const :tag "Don't allow" nil)
272 (const :tag "Prompt to allow" t)
273 (const :tag "Allow without prompting" no-ask))
274 :version "31.1")
275
255;; History of Git commands. 276;; History of Git commands.
256(defvar vc-git-history nil) 277(defvar vc-git-history nil)
257 278
@@ -728,11 +749,13 @@ or an empty string if none."
728 :files files 749 :files files
729 :update-function update-function))) 750 :update-function update-function)))
730 751
752(defun vc-git--current-branch ()
753 (vc-git--out-match '("symbolic-ref" "HEAD")
754 "^\\(refs/heads/\\)?\\(.+\\)$" 2))
755
731(defun vc-git-dir--branch-headers () 756(defun vc-git-dir--branch-headers ()
732 "Return headers for branch-related information." 757 "Return headers for branch-related information."
733 (let ((branch (vc-git--out-match 758 (let ((branch (vc-git--current-branch))
734 '("symbolic-ref" "HEAD")
735 "^\\(refs/heads/\\)?\\(.+\\)$" 2))
736 tracking remote-url) 759 tracking remote-url)
737 (if branch 760 (if branch
738 (when-let ((branch-merge 761 (when-let ((branch-merge
@@ -1082,6 +1105,17 @@ It is based on `log-edit-mode', and has Git-specific extensions."
1082 1105
1083(autoload 'vc-switches "vc") 1106(autoload 'vc-switches "vc")
1084 1107
1108(defun vc-git--log-edit-extract-headers (comment)
1109 (cl-flet ((boolean-arg-fn (argument)
1110 (lambda (v) (and (equal v "yes") (list argument)))))
1111 (log-edit-extract-headers
1112 `(("Author" . "--author")
1113 ("Date" . "--date")
1114 ("Amend" . ,(boolean-arg-fn "--amend"))
1115 ("No-Verify" . ,(boolean-arg-fn "--no-verify"))
1116 ("Sign-Off" . ,(boolean-arg-fn "--signoff")))
1117 comment)))
1118
1085(defun vc-git-checkin (files comment &optional _rev) 1119(defun vc-git-checkin (files comment &optional _rev)
1086 (let* ((file1 (or (car files) default-directory)) 1120 (let* ((file1 (or (car files) default-directory))
1087 (root (vc-git-root file1)) 1121 (root (vc-git-root file1))
@@ -1180,31 +1214,23 @@ It is based on `log-edit-mode', and has Git-specific extensions."
1180 (vc-git-command nil 0 patch-file "apply" "--cached") 1214 (vc-git-command nil 0 patch-file "apply" "--cached")
1181 (delete-file patch-file)))) 1215 (delete-file patch-file))))
1182 (when to-stash (vc-git--stash-staged-changes files))) 1216 (when to-stash (vc-git--stash-staged-changes files)))
1183 (cl-flet ((boolean-arg-fn 1217 ;; When operating on the whole tree, better pass "-a" than ".",
1184 (argument) 1218 ;; since "." fails when we're committing a merge.
1185 (lambda (value) (when (equal value "yes") (list argument))))) 1219 (apply #'vc-git-command nil 0
1186 ;; When operating on the whole tree, better pass "-a" than ".", since "." 1220 (if (and only (not vc-git-patch-string)) files)
1187 ;; fails when we're committing a merge. 1221 (nconc (if msg-file (list "commit" "-F"
1188 (apply #'vc-git-command nil 0 (if (and only (not vc-git-patch-string)) files) 1222 (file-local-name msg-file))
1189 (nconc (if msg-file (list "commit" "-F" 1223 (list "commit" "-m"))
1190 (file-local-name msg-file)) 1224 (let ((args
1191 (list "commit" "-m")) 1225 (vc-git--log-edit-extract-headers comment)))
1192 (let ((args 1226 (when msg-file
1193 (log-edit-extract-headers 1227 (let ((coding-system-for-write
1194 `(("Author" . "--author") 1228 (or pcsw vc-git-commits-coding-system)))
1195 ("Date" . "--date") 1229 (write-region (car args) nil msg-file))
1196 ("Amend" . ,(boolean-arg-fn "--amend")) 1230 (setq args (cdr args)))
1197 ("No-Verify" . ,(boolean-arg-fn "--no-verify")) 1231 args)
1198 ("Sign-Off" . ,(boolean-arg-fn "--signoff"))) 1232 (unless vc-git-patch-string
1199 comment))) 1233 (if only (list "--only" "--") '("-a")))))
1200 (when msg-file
1201 (let ((coding-system-for-write
1202 (or pcsw vc-git-commits-coding-system)))
1203 (write-region (car args) nil msg-file))
1204 (setq args (cdr args)))
1205 args)
1206 (unless vc-git-patch-string
1207 (if only (list "--only" "--") '("-a"))))))
1208 (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file)) 1234 (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file))
1209 (when to-stash 1235 (when to-stash
1210 (let ((cached (make-nearby-temp-file "git-cached"))) 1236 (let ((cached (make-nearby-temp-file "git-cached")))
@@ -1960,6 +1986,94 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
1960 (vc-git-command standard-output 1 nil 1986 (vc-git-command standard-output 1 nil
1961 "log" "--max-count=1" "--pretty=format:%B" rev))) 1987 "log" "--max-count=1" "--pretty=format:%B" rev)))
1962 1988
1989(defun vc-git--assert-allowed-rewrite (rev)
1990 (when (and (not (eq vc-git-allow-rewriting-history 'no-ask))
1991 ;; Check there is an upstream.
1992 (with-temp-buffer
1993 (vc-git--out-ok "config" "--get"
1994 (format "branch.%s.merge"
1995 (vc-git--current-branch)))))
1996 (let ((outgoing (split-string
1997 (with-output-to-string
1998 (vc-git-command standard-output 0 nil "log"
1999 "--pretty=format:%H"
2000 "@{upstream}..HEAD")))))
2001 (unless (or (cl-member rev outgoing :test #'string-prefix-p)
2002 (and vc-git-allow-rewriting-history
2003 (yes-or-no-p
2004 (format
2005"Commit %s looks to be published; are you sure you want to rewrite history?"
2006 rev))))
2007 (user-error "Will not rewrite likely-public Git history")))))
2008
2009(defun vc-git-modify-change-comment (files rev comment)
2010 (vc-git--assert-allowed-rewrite rev)
2011 (let* ((args (delete "--amend"
2012 (vc-git--log-edit-extract-headers comment)))
2013 (message (format "amend! %s\n\n%s" rev (pop args)))
2014 (msg-file
2015 ;; On MS-Windows, pass the message through a file, to work
2016 ;; around how command line arguments must be in the system
2017 ;; codepage, and therefore might not support non-ASCII.
2018 ;;
2019 ;; As our other arguments are static, we need not be concerned
2020 ;; about the encoding of command line arguments in general.
2021 ;; See `vc-git-checkin' for the more complex case.
2022 (and (eq system-type 'windows-nt)
2023 (let ((default-directory
2024 (or (file-name-directory (or (car files)
2025 default-directory))
2026 default-directory)))
2027 (make-nearby-temp-file "git-msg"))))
2028 (nothing-staged
2029 (zerop
2030 (vc-git-command nil t nil "diff" "--cached" "--quiet"))))
2031 ;; We want to do just
2032 ;;
2033 ;; % git commit --only --allow-empty -m...
2034 ;; % git rebase --autostash --autosquash -i REV~1
2035 ;;
2036 ;; because the first command is guaranteed to create an empty commit
2037 ;; regardless of the state of the index and working tree. However,
2038 ;; that requires git.git commit 319d835, released in Git 2.11.1.
2039 ;; In order to support older Git we do this longer, slower sequence:
2040 ;;
2041 ;; % git stash push
2042 ;; % git commit --allow-empty -m...
2043 ;; % git rebase --autosquash -i REV~1
2044 ;; % git stash pop
2045 ;; (unless nothing-staged
2046 ;; (vc-git-command nil 0 nil "stash" "push"))
2047 (unwind-protect
2048 (progn
2049 (when (cl-intersection '("--author" "--date") args
2050 :test #'string=)
2051 ;; 'git rebase --autosquash' cannot alter authorship.
2052 ;; See the description of --fixup in git-commit(1).
2053 (error
2054"Author: and Date: not supported when modifying existing commits"))
2055 (when msg-file
2056 (let ((coding-system-for-write
2057 (or coding-system-for-write
2058 vc-git-commits-coding-system)))
2059 (write-region message nil msg-file)))
2060 (apply #'vc-git-command nil 0 nil
2061 "commit" "--allow-empty"
2062 (nconc (if msg-file
2063 (list "-F" (file-local-name msg-file))
2064 (list "-m" message))
2065 args)))
2066 (when (and msg-file (file-exists-p msg-file))
2067 ;; (delete-file msg-file)
2068 ))
2069 ;; (with-environment-variables (("GIT_SEQUENCE_EDITOR" "true"))
2070 ;; (vc-git-command nil 0 nil "rebase" "--autosquash" "-i"
2071 ;; (format "%s~1" rev)))
2072 ;; (unless nothing-staged
2073 ;; (vc-git-command nil 0 nil "stash" "pop" "--index"))
2074 (message "temporary file is: %s" msg-file)
2075 ))
2076
1963(defvar vc-git-extra-menu-map 2077(defvar vc-git-extra-menu-map
1964 (let ((map (make-sparse-keymap))) 2078 (let ((map (make-sparse-keymap)))
1965 (define-key map [git-grep] 2079 (define-key map [git-grep]