From: Eli Zaretskii Date: Sat, 2 Sep 2023 08:28:17 +0000 (-0400) Subject: Merge from origin/emacs-29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ec3ea8c036a4dd4d7b331081320502c6c8ff1961;p=emacs.git Merge from origin/emacs-29 648a5e33e80 Update to Org 9.6.8-3-g21171d 458442fe78c Escape percent character in treesit--inspect-name (bug#65... bc0426ce8ed Don't add an extraneous slash in remote PATH list in Eshell 34f7a47c9ce Fix Tramp on MS Windows ea5fd6c96bc * Fix native disassemble on Windows platforms (bug#65455) 91d2d8439bb * Handle missing eln file when trying to disassble (bug#6... e7ac50a1539 * lisp/emacs-lisp/comp.el (comp--native-compile): Fix OUT... 45cf3a0cede Update to Transient v0.4.3 31d3808fb9d Adapt Eshell manual 0c50af054f9 Fix applying patches with Git on MS-Windows # Conflicts: # doc/misc/transient.texi # test/lisp/eshell/esh-util-tests.el --- ec3ea8c036a4dd4d7b331081320502c6c8ff1961 diff --cc lisp/vc/vc-git.el index c689eec444b,218696c05f4..9a78264d8ff --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@@ -1099,28 -1038,28 +1099,36 @@@ It is based on `log-edit-mode', and ha (search-forward "diff --git" nil 'move) (move-beginning-of-line 1) (setq file-diff (buffer-substring pos (point))) - (if (and (setq file-beg (string-search - file-diff vc-git-patch-string)) - ;; Check that file diff ends with an empty string - ;; or the beginning of the next file diff. - (string-match-p "\\`\\'\\|\\`diff --git" - (substring - vc-git-patch-string - (+ file-beg (length file-diff))))) - (setq vc-git-patch-string - (string-replace file-diff "" vc-git-patch-string)) - (user-error "Index not empty")) + (cond ((and (setq file-beg (string-search + file-diff vc-git-patch-string)) + ;; Check that file diff ends with an empty string + ;; or the beginning of the next file diff. + (string-match-p "\\`\\'\\|\\`diff --git" + (substring + vc-git-patch-string + (+ file-beg (length file-diff))))) + (setq vc-git-patch-string + (string-replace file-diff "" vc-git-patch-string))) + ((string-match (format "^%s" (regexp-quote file-header)) + vc-git-patch-string) + (if (and file-name + (yes-or-no-p + (format "Unstage already-staged changes to %s?" + file-name))) + (vc-git-command nil 0 file-name "reset" "-q" "--") + (user-error "Index not empty"))) + (t (push file-name to-stash))) (setq pos (point)))))) (unless (string-empty-p vc-git-patch-string) - (let ((patch-file (make-nearby-temp-file "git-patch"))) + (let ((patch-file (make-nearby-temp-file "git-patch")) + ;; Temporarily countermand the let-binding at the + ;; beginning of this function. + (coding-system-for-write + (coding-system-change-eol-conversion + ;; On DOS/Windows, it is important for the patch file + ;; to have the Unix EOL format, because Git expects + ;; that, even on Windows. + (or pcsw vc-git-commits-coding-system) 'unix))) (with-temp-file patch-file (insert vc-git-patch-string)) (unwind-protect diff --cc test/lisp/eshell/esh-util-tests.el index fe4eb9f31dd,9546a4a62fd..7bd71b260ff --- a/test/lisp/eshell/esh-util-tests.el +++ b/test/lisp/eshell/esh-util-tests.el @@@ -60,100 -60,28 +66,124 @@@ "Test that `eshell-stringify' correctly stringifies complex objects." (should (equal (eshell-stringify (list 'quote 'hello)) "'hello"))) +(ert-deftest esh-util-test/eshell-convert-to-number/integer () + "Test that `eshell-convert-to-number' correctly converts integers." + (should (equal (eshell-convert-to-number "123") 123)) + (should (equal (eshell-convert-to-number "-123") -123)) + ;; These are technially integers, since Emacs Lisp requires at least + ;; one digit after the "." to be a float: + (should (equal (eshell-convert-to-number "123.") 123)) + (should (equal (eshell-convert-to-number "-123.") -123))) + +(ert-deftest esh-util-test/eshell-convert-to-number/floating-point () + "Test that `eshell-convert-to-number' correctly converts floats." + (should (equal (eshell-convert-to-number "1.23") 1.23)) + (should (equal (eshell-convert-to-number "-1.23") -1.23)) + (should (equal (eshell-convert-to-number ".1") 0.1)) + (should (equal (eshell-convert-to-number "-.1") -0.1))) + +(ert-deftest esh-util-test/eshell-convert-to-number/floating-point-exponent () + "Test that `eshell-convert-to-number' correctly converts exponent notation." + ;; Positive exponent: + (dolist (exp '("e2" "e+2" "E2" "E+2")) + (should (equal (eshell-convert-to-number (concat "123" exp)) 12300.0)) + (should (equal (eshell-convert-to-number (concat "-123" exp)) -12300.0)) + (should (equal (eshell-convert-to-number (concat "1.23" exp)) 123.0)) + (should (equal (eshell-convert-to-number (concat "-1.23" exp)) -123.0)) + (should (equal (eshell-convert-to-number (concat "1." exp)) 100.0)) + (should (equal (eshell-convert-to-number (concat "-1." exp)) -100.0)) + (should (equal (eshell-convert-to-number (concat ".1" exp)) 10.0)) + (should (equal (eshell-convert-to-number (concat "-.1" exp)) -10.0))) + ;; Negative exponent: + (dolist (exp '("e-2" "E-2")) + (should (equal (eshell-convert-to-number (concat "123" exp)) 1.23)) + (should (equal (eshell-convert-to-number (concat "-123" exp)) -1.23)) + (should (equal (eshell-convert-to-number (concat "1.23" exp)) 0.0123)) + (should (equal (eshell-convert-to-number (concat "-1.23" exp)) -0.0123)) + (should (equal (eshell-convert-to-number (concat "1." exp)) 0.01)) + (should (equal (eshell-convert-to-number (concat "-1." exp)) -0.01)) + (should (equal (eshell-convert-to-number (concat ".1" exp)) 0.001)) + (should (equal (eshell-convert-to-number (concat "-.1" exp)) -0.001)))) + +(ert-deftest esh-util-test/eshell-convert-to-number/floating-point/infinite () + "Test that `eshell-convert-to-number' correctly converts infinite floats." + (should (equal (eshell-convert-to-number "1.0e+INF") 1.0e+INF)) + (should (equal (eshell-convert-to-number "2.e+INF") 1.0e+INF)) + (should (equal (eshell-convert-to-number "-1.0e+INF") -1.0e+INF)) + (should (equal (eshell-convert-to-number "-2.e+INF") -1.0e+INF))) + +(ert-deftest esh-util-test/eshell-convert-to-number/floating-point/nan () + "Test that `eshell-convert-to-number' correctly converts NaNs." + (should (equal (eshell-convert-to-number "1.0e+NaN") 1.0e+NaN)) + (should (equal (eshell-convert-to-number "2.e+NaN") 2.0e+NaN)) + (should (equal (eshell-convert-to-number "-1.0e+NaN") -1.0e+NaN)) + (should (equal (eshell-convert-to-number "-2.e+NaN") -2.0e+NaN))) + +(ert-deftest esh-util-test/eshell-convert-to-number/non-numeric () + "Test that `eshell-convert-to-number' does nothing to non-numeric values." + (should (equal (eshell-convert-to-number "foo") "foo")) + (should (equal (eshell-convert-to-number "") "")) + (should (equal (eshell-convert-to-number "123foo") "123foo"))) + +(ert-deftest esh-util-test/eshell-convert-to-number/no-convert () + "Test that `eshell-convert-to-number' does nothing when disabled." + (let ((eshell-convert-numeric-arguments nil)) + (should (equal (eshell-convert-to-number "123") "123")) + (should (equal (eshell-convert-to-number "1.23") "1.23")))) + +(ert-deftest esh-util-test/eshell-printable-size () + (should (equal (eshell-printable-size (expt 2 16)) "65536")) + (should (equal (eshell-printable-size (expt 2 32)) "4294967296"))) + +(ert-deftest esh-util-test/eshell-printable-size/zero () + (should (equal (eshell-printable-size 0 1000 nil t) "0"))) + +(ert-deftest esh-util-test/eshell-printable-size/terabyte () + (should (equal (eshell-printable-size (1- (expt 2 40)) 1024 nil t) "1024G")) + (should (equal (eshell-printable-size (expt 2 40) 1024 nil t) "1T")) + (should (equal (eshell-printable-size (1- (expt 10 12)) 1000 nil t) "1000G")) + (should (equal (eshell-printable-size (expt 10 12) 1000 nil t) "1T"))) + +(ert-deftest esh-util-test/eshell-printable-size/use-colors () + (should (equal-including-properties + (eshell-printable-size (1- (expt 2 20)) 1024 nil t) + "1024k")) + (should (equal-including-properties + (eshell-printable-size (1- (expt 2 30)) 1024 nil t) + (propertize "1024M" 'face 'bold))) + (should (equal-including-properties + (eshell-printable-size (1- (expt 2 40)) 1024 nil t) + (propertize "1024G" 'face 'bold-italic)))) + +(ert-deftest esh-util-test/eshell-printable-size/block-size () + (should (equal (eshell-printable-size (1- (expt 2 20)) nil 4096) "256")) + (should (equal (eshell-printable-size (1- (expt 2 30)) nil 4096) "262144"))) + +(ert-deftest esh-util-test/eshell-printable-size/human-readable-arg () + (should-error (eshell-printable-size 0 999 nil t))) + + (ert-deftest esh-util-test/path/get () + "Test that getting the Eshell path returns the expected results." + (let ((expected-path (butlast (exec-path)))) + (should (equal (eshell-get-path) + (if (eshell-under-windows-p) + (cons "." expected-path) + expected-path))) + (should (equal (eshell-get-path 'literal) + expected-path)))) + + (ert-deftest esh-util-test/path/get-remote () + "Test that getting the remote Eshell path returns the expected results." + (let* ((default-directory ert-remote-temporary-file-directory) + (expected-path (butlast (exec-path)))) + ;; Make sure we don't have a doubled directory separator. + (should (seq-every-p (lambda (i) (not (string-match-p "//" i))) + (eshell-get-path))) + (should (equal (eshell-get-path) + (mapcar (lambda (i) + (concat (file-remote-p default-directory) i)) + expected-path))) + (should (equal (eshell-get-path 'literal) + expected-path)))) + ;;; esh-util-tests.el ends here