emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 76fe394953: magit-log-merged: Fix incorrect cal


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 76fe394953: magit-log-merged: Fix incorrect calculation of distance from tip
Date: Sun, 29 Jan 2023 00:59:00 -0500 (EST)

branch: elpa/git-commit
commit 76fe394953281fd9a9b68b2cfd0873bfa20ff269
Author: Brennan Vincent <brennan@umanwizard.com>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-log-merged: Fix incorrect calculation of distance from tip
    
    When calculating the distance of a commit that is actually on a branch
    from the tip of that branch (i.e., the <N> such that branch~<N>
    identifies that commit), we should only count the path along first
    parents, as that is how the syntax branch~<N> is defined. Before this
    commit, we were counting _all_ commits between the commit and the tip
    of the branch, which is more than the correct number, in the case that
    the history between commit and branch is non-linear. Thus, the point
    around which we log was chosen incorrectly, and an incorrect set of
    commits was shown in the resulting log.
---
 lisp/magit-git.el | 7 +++++--
 lisp/magit-log.el | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 0d30b83eef..5a19f74cef 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2154,12 +2154,15 @@ exists in the current repository is considered its main 
branch."
                      (cons (magit-get "init.defaultBranch")
                            magit-main-branch-names))))))
 
-(defun magit-rev-diff-count (a b)
+(defun magit-rev-diff-count (a b &optional first-parent)
   "Return the commits in A but not B and vice versa.
-Return a list of two integers: (A>B B>A)."
+Return a list of two integers: (A>B B>A).
+
+If `first-parent' is set, traverse only first parents."
   (mapcar #'string-to-number
           (split-string (magit-git-string "rev-list"
                                           "--count" "--left-right"
+                                          (and first-parent "--first-parent")
                                           (concat a "..." b))
                         "\t")))
 
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index ad62cbabd1..4d55ae1069 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -845,7 +845,7 @@ https://github.com/mhagger/git-when-merged.";
       (if (equal m "Commit is directly on this branch.")
           (let* ((from (format "%s~%d" commit
                                (/ magit-log-merged-commit-count 2)))
-                 (to (- (car (magit-rev-diff-count branch commit))
+                 (to (- (car (magit-rev-diff-count branch commit t))
                         (/ magit-log-merged-commit-count 2)))
                  (to (if (<= to 0)
                          branch



reply via email to

[Prev in Thread] Current Thread [Next in Thread]