From: Sean Whitton Date: Sun, 29 Jun 2025 13:53:37 +0000 (+0100) Subject: VC: Fix several START-REVISION versus LIMIT issues X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=86235ca52250c059688aff1453b99fd16927f0fc;p=emacs.git VC: Fix several START-REVISION versus LIMIT issues * lisp/vc/vc-git.el (vc-git-print-log): When LIMIT and START-REVISION are both supplied, use START-REVISION as the newest commit, and LIMIT as a base (problem was introduced in the commit adding 'vc-diff-mergebase' and 'vc-log-mergebase'). * lisp/vc/vc.el (vc-default-log-incoming) (vc-default-log-outgoing): Fix order of START-REVISION and LIMIT arguments passed to 'print-log' backend function. (vc-log-mergebase): Fix order of START-REVISION and LIMIT arguments passed to 'vc-print-log-internal'. (cherry picked from commit d23b605f754d07a9abf298353d7d17197094477b) --- diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 9ab82f7f5ac..89aa98fec8b 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1560,7 +1560,7 @@ If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'. \(This requires at least Git version 1.5.6, for the --graph option.) If START-REVISION is non-nil, it is the newest revision to show. If LIMIT is a number, show no more than this many entries. -If LIMIT is a revision string, use it as an end-revision." +If LIMIT is a non-empty string, use it as a base." (let ((coding-system-for-read (or coding-system-for-read vc-git-log-output-coding-system))) ;; `vc-do-command' creates the buffer, but we need it before running @@ -1568,7 +1568,19 @@ If LIMIT is a revision string, use it as an end-revision." (vc-setup-buffer buffer) ;; If the buffer exists from a previous invocation it might be ;; read-only. - (let ((inhibit-read-only t)) + (let ((inhibit-read-only t) + ;; In some parts of Git's revision and revision range + ;; notation, an empty string is equivalent to "HEAD", but not + ;; everywhere. For simplicity we'll always be explicit. + (start-revision (if (member start-revision '(nil "")) + "HEAD" + start-revision)) + ;; An empty string LIMIT doesn't make sense given the + ;; specification of this VC backend function, and is tricky to + ;; deal with in combination with Git's double-dot notation for + ;; specifying revision ranges. So discard it right away. + (limit (and (not (equal limit "")) + limit))) (with-current-buffer buffer (apply #'vc-git-command buffer 'async files @@ -1591,14 +1603,11 @@ If LIMIT is a revision string, use it as an end-revision." (if shortlog vc-git-shortlog-switches vc-git-log-switches)) (when (numberp limit) (list "-n" (format "%s" limit))) - (when start-revision - (if (and limit (not (numberp limit))) - (list (concat start-revision ".." (if (equal limit "") - "HEAD" - limit))) - (list start-revision))) (when (eq vc-log-view-type 'with-diff) (list "-p")) + (list (concat (and (stringp limit) + (concat limit "..")) + start-revision)) '("--"))))))) (defun vc-git-incoming-revision (remote-location) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index b06f3f9103d..868f8e5d775 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -347,7 +347,8 @@ ;; Insert the revision log for FILES into BUFFER. ;; If SHORTLOG is non-nil insert a short version of the log. ;; If LIMIT is non-nil insert only insert LIMIT log entries. -;; When LIMIT is a string it means stop at that revision. +;; When LIMIT is a string it means stop right before that revision +;; (i.e., revision LIMIT itself should not be included in the log). ;; If the backend does not support limiting the number of entries to ;; show it should return `limit-unsupported'. ;; If START-REVISION is given, then show the log starting from that @@ -3305,8 +3306,8 @@ In some version control systems REMOTE-LOCATION can be a remote branch name." remote-location) (user-error "No incoming revision -- local-only branch?")))) (vc-call-backend backend 'print-log (list rootdir) buffer t - (vc-call-backend backend 'mergebase incoming) - incoming)))) + incoming + (vc-call-backend backend 'mergebase incoming))))) ;;;###autoload (defun vc-log-outgoing (&optional remote-location) @@ -3327,8 +3328,8 @@ In some version control systems REMOTE-LOCATION can be a remote branch name." remote-location) (user-error "No incoming revision -- local-only branch?")))) (vc-call-backend backend 'print-log (list rootdir) buffer t - (vc-call-backend backend 'mergebase incoming) - "")))) + "" + (vc-call-backend backend 'mergebase incoming))))) ;;;###autoload (defun vc-log-search (pattern) @@ -3362,7 +3363,7 @@ The merge base is a common ancestor of revisions REV1 and REV2." (list backend (list (vc-call-backend backend 'root default-directory))))))) (vc--with-backend-in-rootdir "VC root-log" (setq rev1 (vc-call-backend backend 'mergebase rev1 rev2)) - (vc-print-log-internal backend (list rootdir) rev1 t (or rev2 "")))) + (vc-print-log-internal backend (list rootdir) (or rev2 "") t rev1))) ;;;###autoload (defun vc-region-history (from to)