]> git.eshelyaron.com Git - emacs.git/commitdiff
Use short revisions by default when navigating to revisions
authorJim Porter <jporterbugs@gmail.com>
Wed, 25 Jun 2025 05:50:22 +0000 (22:50 -0700)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:45:56 +0000 (09:45 +0200)
* lisp/vc/vc-annotate.el (vc-annotate-revision-previous-to-line)
(vc-annotate-show-diff-revision-at-line-internal)
(vc-annotate-warp-revision): Let-bind 'vc-use-short-revision'
around calls to 'previous-revision' and 'next-revision'.

* lisp/vc/vc-git.el (vc-git-previous-revision, vc-git-next-revision):
Handle 'vc-use-short-revision' option (bug#78900).

(cherry picked from commit e88af5fff7fbb148a5ddad377219336dc22500b1)

lisp/vc/vc-annotate.el
lisp/vc/vc-git.el

index 4f72faacaaf867d75ef54b9bebc6ab5bdd3cc133..e68c5a799191ab52624e61cf21cb9d7a15a4242c 100644 (file)
@@ -557,8 +557,9 @@ Return a cons (REV . FILENAME)."
       (if (not rev-at-line)
          (message "Cannot extract revision number from the current line")
        (setq prev-rev
-             (vc-call-backend vc-annotate-backend 'previous-revision
-                               fname rev))
+              (let ((vc-use-short-revision vc-annotate-use-short-revision))
+                (vc-call-backend vc-annotate-backend 'previous-revision
+                                 fname rev)))
        (if (not prev-rev)
             (message "No previous revisions")
           (vc-annotate-warp-revision prev-rev fname))))))
@@ -613,8 +614,9 @@ the file in question, search for the log entry required and move point."
       (if (not rev-at-line)
          (message "Cannot extract revision number from the current line")
        (setq prev-rev
-             (vc-call-backend vc-annotate-backend 'previous-revision
-                               (if filediff fname nil) rev))
+              (let ((vc-use-short-revision vc-annotate-use-short-revision))
+                (vc-call-backend vc-annotate-backend 'previous-revision
+                                 (if filediff fname nil) rev)))
        (vc-diff-internal
          vc-allow-async-diff
          ;; The value passed here should follow what
@@ -658,23 +660,27 @@ describes a revision number, so warp to that revision."
       (cond
        ((and (integerp revspec) (> revspec 0))
        (setq newrev vc-buffer-revision)
-       (while (and (> revspec 0) newrev)
-          (setq newrev (vc-call-backend vc-annotate-backend 'next-revision
-                                        (or file
-                                            (caadr vc-buffer-overriding-fileset))
-                                        newrev))
-          (setq revspec (1- revspec)))
+        (let ((vc-use-short-revision vc-annotate-use-short-revision))
+         (while (and (> revspec 0) newrev)
+            (setq newrev
+                  (vc-call-backend vc-annotate-backend 'next-revision
+                                   (or file
+                                       (caadr vc-buffer-overriding-fileset))
+                                   newrev))
+            (setq revspec (1- revspec))))
        (unless newrev
          (message "Cannot increment %d revisions from revision %s"
                   revspeccopy vc-buffer-revision)))
        ((and (integerp revspec) (< revspec 0))
        (setq newrev vc-buffer-revision)
-       (while (and (< revspec 0) newrev)
-          (setq newrev (vc-call-backend vc-annotate-backend 'previous-revision
-                                        (or file
-                                            (caadr vc-buffer-overriding-fileset))
-                                        newrev))
-          (setq revspec (1+ revspec)))
+        (let ((vc-use-short-revision vc-annotate-use-short-revision))
+         (while (and (< revspec 0) newrev)
+            (setq newrev
+                  (vc-call-backend vc-annotate-backend 'previous-revision
+                                   (or file
+                                       (caadr vc-buffer-overriding-fileset))
+                                   newrev))
+            (setq revspec (1+ revspec))))
        (unless newrev
          (message "Cannot decrement %d revisions from revision %s"
                   (- 0 revspeccopy) vc-buffer-revision)))
index eb0465cd0d56c5438378e722a5d86cf9d44031b5..9075ceed63479f18f48a7b885ef358a70e27af34 100644 (file)
@@ -1937,13 +1937,18 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
 
 ;;; MISCELLANEOUS
 
+(defsubst vc-git--maybe-abbrev ()
+  (if vc-use-short-revision "--abbrev-commit" "--no-abbrev-commit"))
+
 (defun vc-git-previous-revision (file rev)
   "Git-specific version of `vc-previous-revision'."
   (if file
       (let* ((fname (file-relative-name file))
              (prev-rev (with-temp-buffer
                          (and
-                          (vc-git--out-ok "rev-list" "-2" rev "--" fname)
+                          (vc-git--out-ok "rev-list"
+                                          (vc-git--maybe-abbrev)
+                                          "-2" rev "--" fname)
                           (goto-char (point-max))
                           (bolp)
                           (zerop (forward-line -1))
@@ -1974,7 +1979,9 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
          (current-rev
           (with-temp-buffer
             (and
-             (vc-git--out-ok "rev-list" "-1" rev "--" file)
+             (vc-git--out-ok "rev-list"
+                             (vc-git--maybe-abbrev)
+                             "-1" rev "--" file)
              (goto-char (point-max))
              (bolp)
              (zerop (forward-line -1))
@@ -1986,7 +1993,9 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
           (and current-rev
                (with-temp-buffer
                  (and
-                  (vc-git--out-ok "rev-list" "HEAD" "--" file)
+                  (vc-git--out-ok "rev-list"
+                                  (vc-git--maybe-abbrev)
+                                  "HEAD" "--" file)
                   (goto-char (point-min))
                   (search-forward current-rev nil t)
                   (zerop (forward-line -1))