GNU bug report logs - #33950
27.0.50; Merge-base alias for git vc-diff

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Wed, 2 Jan 2019 00:13:02 UTC

Severity: wishlist

Tags: patch

Found in version 27.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33950 in the body.
You can then email your comments to 33950 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#33950; Package emacs. (Wed, 02 Jan 2019 00:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 02 Jan 2019 00:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Merge-base alias for git vc-diff
Date: Wed, 02 Jan 2019 02:11:17 +0200
[Message part 1 (text/plain, inline)]
Following https://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00446.html
here's the patch that implement this feature:

[vc-mergebase.patch (text/x-diff, inline)]
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 84e11f2e01..f32e536981 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -890,6 +890,8 @@ vc-prefix-map
     (define-key map "L" 'vc-print-root-log)
     (define-key map "I" 'vc-log-incoming)
     (define-key map "O" 'vc-log-outgoing)
+    (define-key map "ML" 'vc-log-mergebase)
+    (define-key map "MD" 'vc-diff-mergebase)
     (define-key map "m" 'vc-merge)
     (define-key map "r" 'vc-retrieve-tag)
     (define-key map "s" 'vc-create-tag)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 48b7c98dfa..ccd03c4427 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -429,6 +429,10 @@
 ;; - region-history-mode ()
 ;;
 ;;   Major mode to use for the output of `region-history'.
+;;
+;; - mergebase (rev1 &optional rev2)
+;;
+;;   Return the common ancestor between REV1 and REV2 revisions.
 
 ;; TAG SYSTEM
 ;;
@@ -1849,6 +1853,30 @@ vc-root-version-diff
        t (list backend (list rootdir)) rev1 rev2
        (called-interactively-p 'interactive)))))
 
+
+;;;###autoload
+(defun vc-diff-mergebase (_files rev1 rev2)
+  "Report diffs between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions."
+  (interactive (vc-diff-build-argument-list-internal))
+  (when (and (not rev1) rev2)
+    (error "Not a valid revision range"))
+  (let ((backend (vc-deduce-backend))
+        (default-directory default-directory)
+        rootdir)
+    (if backend
+        (setq rootdir (vc-call-backend backend 'root default-directory))
+      (setq rootdir (read-directory-name "Directory for VC root-diff: "))
+      (setq backend (vc-responsible-backend rootdir))
+      (if backend
+          (setq default-directory rootdir)
+        (error "Directory is not version controlled")))
+    (let ((default-directory rootdir)
+          (rev1 (vc-call-backend backend 'mergebase rev1 rev2)))
+      (vc-diff-internal
+       t (list backend (list rootdir)) rev1 rev2
+       (called-interactively-p 'interactive)))))
+
 ;;;###autoload
 (defun vc-diff (&optional historic not-urgent)
   "Display diffs between file revisions.
@@ -2491,6 +2519,25 @@ vc-log-outgoing
     (vc-incoming-outgoing-internal backend (or remote-location "")
                                    "*vc-outgoing*" 'log-outgoing)))
 
+;;;###autoload
+(defun vc-log-mergebase (_files rev1 rev2)
+  "Show a log of changes between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions."
+  (interactive (vc-diff-build-argument-list-internal))
+  (let ((backend (vc-deduce-backend))
+	(default-directory default-directory)
+	rootdir)
+    (if backend
+	(setq rootdir (vc-call-backend backend 'root default-directory))
+      (setq rootdir (read-directory-name "Directory for VC root-log: "))
+      (setq backend (vc-responsible-backend rootdir))
+      (unless backend
+        (error "Directory is not version controlled")))
+    (setq default-directory rootdir)
+    (unless rev2 (setq rev2 "HEAD"))
+    (setq rev1 (vc-call-backend backend 'mergebase rev1 rev2))
+    (vc-print-log-internal backend (list rootdir) rev1 t rev2)))
+
 ;;;###autoload
 (defun vc-region-history (from to)
   "Show the history of the region between FROM and TO.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index aa6809f626..82ff2b58e7 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1045,8 +1045,12 @@ vc-git-print-log
                     ,(format "--pretty=tformat:%s"
 			     (car vc-git-root-log-format))
 		    "--abbrev-commit"))
-		(when limit (list "-n" (format "%s" limit)))
-		(when start-revision (list start-revision))
+		(when (numberp limit)
+                  (list "-n" (format "%s" limit)))
+		(when start-revision
+                  (if (and limit (not (numberp limit)))
+                      (list (concat start-revision ".." limit))
+                    (list start-revision)))
 		'("--")))))))
 
 (defun vc-git-log-outgoing (buffer remote-location)
@@ -1077,6 +1081,12 @@ vc-git-log-incoming
 			"@{upstream}"
 		      remote-location))))
 
+(eval-when-compile (require 'subr-x)) ; for string-trim-right
+
+(defun vc-git-mergebase (rev1 &optional rev2)
+  (unless rev2 (setq rev2 "HEAD"))
+  (string-trim-right (vc-git--run-command-string nil "merge-base" rev1 rev2)))
+
 (defvar log-view-message-re)
 (defvar log-view-file-re)
 (defvar log-view-font-lock-keywords)

Severity set to 'wishlist' from 'normal' Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 02 Jan 2019 00:28:01 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 02 Jan 2019 00:28:02 GMT) Full text and rfc822 format available.

Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Mon, 25 Mar 2019 21:47:01 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> linkov.net>:
bug acknowledged by developer. (Mon, 25 Mar 2019 21:47:02 GMT) Full text and rfc822 format available.

Message #14 received at 33950-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 33950-done <at> debbugs.gnu.org
Subject: Re: bug#33950: 27.0.50; Merge-base alias for git vc-diff
Date: Mon, 25 Mar 2019 23:45:42 +0200
> Following https://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00446.html
> here's the patch that implement this feature:

Today a coworker asked me how she can view all changes on her branch
so she could revert one of them.  I showed her how easy is just to
type 'C-x v M D' (vc-diff-mergebase) and enter two revisions: master
and the name of her branch, that quickly solved her problem.

So now I installed this feature that demonstrated its easy use.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33950; Package emacs. (Mon, 01 Apr 2019 23:30:01 GMT) Full text and rfc822 format available.

Message #17 received at 33950 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: 33950 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#33950: 27.0.50; Merge-base alias for git vc-diff
Date: Tue, 2 Apr 2019 02:29:11 +0300
On 25.03.2019 23:45, Juri Linkov wrote:
>> Following https://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00446.html
>> here's the patch that implement this feature:
> 
> Today a coworker asked me how she can view all changes on her branch
> so she could revert one of them.  I showed her how easy is just to
> type 'C-x v M D' (vc-diff-mergebase) and enter two revisions: master
> and the name of her branch, that quickly solved her problem.
> 
> So now I installed this feature that demonstrated its easy use.

Thank you, and good job!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 30 Apr 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 356 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.