From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Merge-base alias for git vc-diff Date: Thu, 10 Jan 2019 23:25:23 +0200 Organization: LINKOV.NET Message-ID: <874lag9s5q.fsf@mail.linkov.net> References: <87bm58ornb.fsf@mail.linkov.net> <92f058a4-ef98-725b-9603-5a671113dfaa@yandex.ru> <87lg4aak10.fsf@mail.linkov.net> <87o98zapae.fsf@mail.linkov.net> <87ef9u951h.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1547157859 30604 195.159.176.226 (10 Jan 2019 22:04:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 Jan 2019 22:04:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 10 23:04:14 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ghiQv-0007rf-B4 for ged-emacs-devel@m.gmane.org; Thu, 10 Jan 2019 23:04:13 +0100 Original-Received: from localhost ([127.0.0.1]:50728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghiT0-0000FE-Hu for ged-emacs-devel@m.gmane.org; Thu, 10 Jan 2019 17:06:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:32896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghiQz-00075Q-0Y for emacs-devel@gnu.org; Thu, 10 Jan 2019 17:04:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghiNQ-0003gK-UM for emacs-devel@gnu.org; Thu, 10 Jan 2019 17:00:38 -0500 Original-Received: from quail.birch.relay.mailchannels.net ([23.83.209.151]:61694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghiNN-0003cV-Tv for emacs-devel@gnu.org; Thu, 10 Jan 2019 17:00:35 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3091C121ECF; Thu, 10 Jan 2019 22:00:27 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (unknown [100.96.33.121]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 551FB12540B; Thu, 10 Jan 2019 22:00:15 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Thu, 10 Jan 2019 22:00:27 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Spot-Illustrious: 3134722e015b0346_1547157615633_3321782355 X-MC-Loop-Signature: 1547157615633:2912588427 X-MC-Ingress-Time: 1547157615632 Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a54.g.dreamhost.com (Postfix) with ESMTP id 7881E803C2; Thu, 10 Jan 2019 14:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=nrptzQercyOe7oclVP5dCrfZgRU=; b= JiTjJ0VHiR/7oN8Ile6QKD8FkcfRjQKFRAeSNLNtyM5kNAF+YTIPqh+9NiJ+KyRN TlwX5cED98uNUFYziK+vkbeUlm7IXQ3SIsX5pHxo/M8TS9aW52gbADVtKwZN+eQb uzliWGQ6ngU2cpLSgeG0+HLVgwd1v3G0iSCAPxUkHRE= Original-Received: from mail.jurta.org (m91-129-101-91.cust.tele2.ee [91.129.101.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a54.g.dreamhost.com (Postfix) with ESMTPSA id 4ABF8803B8; Thu, 10 Jan 2019 14:00:08 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a54 In-Reply-To: (Stefan Monnier's message of "Wed, 02 Jan 2019 22:40:30 -0500") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeefgdduheejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucffohhmrghinhepvghlrdhithenucfkphepledurdduvdelrddutddurdeludenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrddutddurdeluddprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehmohhnnhhivghrsefktffqrdgfofhonhhtrhgvrghlrdevteenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.209.151 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232295 Archived-At: >> 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