[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Merge-base alias for git vc-diff
From: |
Juri Linkov |
Subject: |
Re: Merge-base alias for git vc-diff |
Date: |
Thu, 10 Jan 2019 23:25:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>> 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
- Re: Merge-base alias for git vc-diff, (continued)
- Re: Merge-base alias for git vc-diff, Stefan Monnier, 2019/01/02
- Re: Merge-base alias for git vc-diff, João Távora, 2019/01/03
- Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/03
- Re: Merge-base alias for git vc-diff, João Távora, 2019/01/03
- Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/05
- Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/07
- Re: Merge-base alias for git vc-diff, Stefan Monnier, 2019/01/08
- Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/08
Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/02
Re: Merge-base alias for git vc-diff, Stefan Monnier, 2019/01/10
Re: Merge-base alias for git vc-diff, Juri Linkov, 2019/01/10