all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Merge-base alias for git vc-diff
Date: Thu, 10 Jan 2019 23:25:23 +0200	[thread overview]
Message-ID: <874lag9s5q.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwva7kis95f.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 02 Jan 2019 22:40:30 -0500")

>> The reason I proposed separate commands is because I can't find
>> a good solution how to combine this with the existing commands.
>
> You'd have to change the notion of "revision" in vc-git.el to allow
> a leading or trailing "...": remember, this is specific to Git so it can
> only belong in vc-git.el.
>
> It also means that revision completion in C-x v ~ will also allow those
> "..." even tho they don't make any sense there.

After trying to implement this with

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index f9ea4def15..8f8e151549 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1247,4 +1249,10 @@ vc-git-diff
       (setq command "diff-index")
       (unless rev1 (setq rev1 "HEAD")))
+    (when (string-match "\\`\\(.*\\)\\.\\.\\.\\'" rev1)
+      (setq rev1 (string-trim-right (or (vc-git--run-command-string
+                                         nil "merge-base"
+                                         (match-string 1 rev1)
+                                         rev2)
+                                        (match-string 1 rev1)))))
     (if vc-git-diff-switches
         (apply #'vc-git-command (or buffer "*vc-diff*")

and using with `C-u C-x v D master... RET branch RET'
exposed an unexpected problem: vc-diff-internal sets
diff-vc-revisions to the list ("master..." "branch")

But diff-mode fails to use diff-vc-revisions for such features as
jumping to the corresponding source line with diff-goto-source that
signals an error in vc-git-find-revision:

  (error "Failed (status 128): git --no-pager cat-file blob master...:lisp/vc/vc-git.el .")

and leaves the buffer with an error message in it:

  fatal: Not a valid object name master...:lisp/vc/vc-git.el

One way to resolve this is to interpret "master...branch" as a syntax
to denote the merge base, then set diff-vc-revisions instead of

  ("master..." "branch")

to

  ("master...branch" "branch")

This means that this feature should be used only this way:

  C-u C-x v D master...branch RET branch RET



  reply	other threads:[~2019-01-10 21:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-26 22:32 Merge-base alias for git vc-diff Juri Linkov
2018-12-27  1:07 ` Dmitry Gutov
2018-12-27 20:02   ` Juri Linkov
2018-12-27 20:42     ` Dmitry Gutov
2018-12-28 17:53     ` Stefan Monnier
2018-12-29 21:39       ` Juri Linkov
2019-01-02  0:14     ` Juri Linkov
2019-01-02  1:55       ` Stefan Monnier
2019-01-02 15:34         ` João Távora
2019-01-02 22:25           ` Dmitry Gutov
2019-01-02 22:48             ` João Távora
2019-01-02 23:07               ` Dmitry Gutov
2019-01-03  3:22               ` Stefan Monnier
2019-01-03 13:30                 ` João Távora
2019-01-03 20:38                   ` Juri Linkov
2019-01-03 21:44                     ` João Távora
2019-01-05 22:28                       ` Juri Linkov
2019-01-07 22:33                       ` Juri Linkov
2019-01-08 14:58                         ` Stefan Monnier
2019-01-09  0:05                           ` Juri Linkov
2019-01-02 21:29         ` Juri Linkov
2019-01-03  3:40           ` Stefan Monnier
2019-01-10 21:25             ` Juri Linkov [this message]
2019-01-10 22:14               ` Dmitry Gutov
2019-01-10 23:25                 ` Juri Linkov
2019-01-10 22:41               ` Stefan Monnier
2019-01-10 23:18                 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lag9s5q.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.