GNU bug report logs - #19099
Diff options with vc-git

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 18 Nov 2014 19:10:02 UTC

Severity: normal

Found in version 24.4

Done: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>

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 19099 in the body.
You can then email your comments to 19099 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#19099; Package emacs. (Tue, 18 Nov 2014 19:10:03 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: Diff options with vc-git
Date: Tue, 18 Nov 2014 14:09:53 -0500
Package: emacs
Version: 24.4

I would like to use context diffs with vc-diff. Or pretend I said "any
GNU diff option that git diff does not support".

If I

(setq diff-switches '("-c" -w"))

then it works fine with vc-bzr, which correctly converts these into
"--diff-options" for bzr diff. Same for vc-svn, which automatically adds
--diff-cmd.

With vc-git this does nothing. Setting vc-git-diff-switches to nil
doesn't do the right thing: it passes -c to "git diff", which
interprets it as "--combined", which is not what I wanted.

IIUC there's basically no way to get this with git diff, I have to use
  
   difftool -x "diff -c"

(which seems to parse its -x argument on whitespace, yuck).

So, TLDR:

I'd like an option to call difftool instead of diff in vc-git-diff, please.
If it was consistent with eg vc-svn, this would happen by default when
vc-git-diff-switches was nil.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Tue, 18 Nov 2014 19:19:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: Diff options with vc-git
Date: Tue, 18 Nov 2014 21:17:53 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Tue, 18 Nov 2014 14:09:53 -0500
> 
> IIUC there's basically no way to get this with git diff, I have to use
>   
>    difftool -x "diff -c"
> 
> (which seems to parse its -x argument on whitespace, yuck).
> 
> So, TLDR:
> 
> I'd like an option to call difftool instead of diff in vc-git-diff, please.
> If it was consistent with eg vc-svn, this would happen by default when
> vc-git-diff-switches was nil.

You can make an alias as described here:

  http://stackoverflow.com/questions/3129514/how-to-make-git-diff-create-a-context-format-diff

and then invoke that alias instead of "diff".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Tue, 18 Nov 2014 19:28:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: Diff options with vc-git
Date: Tue, 18 Nov 2014 14:27:22 -0500
Eli Zaretskii wrote:

> You can make an alias as described here:
>
>   http://stackoverflow.com/questions/3129514/how-to-make-git-diff-create-a-context-format-diff
>
> and then invoke that alias instead of "diff".

Git aliases cannot override built-in git commands. (By design, wontfix, etc.)
So I cannot make "git diff" do what I want.

If you think otherwise, please give me a concrete example of how I can
configure Emacs to do what I want.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Tue, 18 Nov 2014 19:59:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: Diff options with vc-git
Date: Tue, 18 Nov 2014 21:57:57 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: 19099 <at> debbugs.gnu.org
> Date: Tue, 18 Nov 2014 14:27:22 -0500
> 
> > and then invoke that alias instead of "diff".
> 
> Git aliases cannot override built-in git commands. (By design, wontfix, etc.)
> So I cannot make "git diff" do what I want.

I said "alias +instead_ of diff", didn't I?

> If you think otherwise, please give me a concrete example of how I can
> configure Emacs to do what I want.

Introduce a defcustom that will allow to all "git SOMETHING" when VC
wants a diff command.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Tue, 18 Nov 2014 20:02:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: rgm <at> gnu.org
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: Diff options with vc-git
Date: Tue, 18 Nov 2014 22:01:25 +0200
> Date: Tue, 18 Nov 2014 21:57:57 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 19099 <at> debbugs.gnu.org
> 
> Introduce a defcustom that will allow to all "git SOMETHING" when VC
> wants a diff command.                    ^^^

I meant "call", of course.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Wed, 19 Nov 2014 04:02:02 GMT) Full text and rfc822 format available.

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

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
To: 19099 <at> debbugs.gnu.org
Subject: [PATCH] vc-git: Support `diff-switches'.
Date: Wed, 19 Nov 2014 04:03:17 +0100
This patch should add support for it.  Please check if it works for you.

ChangeLog:

Fix bug#19099.
* lisp/vc/vc-git.el (vc-git-diff): Use "difftool -x diff" with
  `diff-switches' if `vc-git-diff-switches' is nil.
---
 lisp/vc/vc-git.el | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index be0211c..3b11a3c 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -994,11 +994,18 @@ (autoload 'vc-switches "vc")
 (defun vc-git-diff (files &optional rev1 rev2 buffer)
   "Get a difference report using Git between two revisions of FILES."
   (let (process-file-side-effects)
-    (apply #'vc-git-command (or buffer "*vc-diff*") 1 files
-	   (if (and rev1 rev2) "diff-tree" "diff-index")
-	   "--exit-code"
-	   (append (vc-switches 'git 'diff)
-		   (list "-p" (or rev1 "HEAD") rev2 "--")))))
+    (if vc-git-diff-switches
+        (apply #'vc-git-command (or buffer "*vc-diff*") 1 files
+               (if (and rev1 rev2) "diff-tree" "diff-index")
+               "--exit-code"
+               (append (vc-switches 'git 'diff)
+                       (list "-p" (or rev1 "HEAD") rev2 "--")))
+      (vc-git-command (or buffer "*vc-diff*") 1 files
+                      "difftool" "--exit-code" "--no-prompt" "-x"
+                      (concat "diff "
+                              (mapconcat 'identity
+                                         (vc-switches nil 'diff) " "))
+                      (or rev1 "HEAD") rev2 "--"))))
 
 (defun vc-git-revision-table (_files)
   ;; What about `files'?!?  --Stef
-- 
2.1.3





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Wed, 19 Nov 2014 04:37:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: [PATCH] vc-git: Support `diff-switches'.
Date: Tue, 18 Nov 2014 23:36:11 -0500
Thanks, works for me, and seems to neatly avoid being an incompatible
change wrt vc-git-diff-switches being non-nil and non-t.
BTW, I appreciate how you often try to improve git-related things.




Reply sent to Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>:
You have taken responsibility. (Wed, 19 Nov 2014 11:14:02 GMT) Full text and rfc822 format available.

Notification sent to Glenn Morris <rgm <at> gnu.org>:
bug acknowledged by developer. (Wed, 19 Nov 2014 11:14:03 GMT) Full text and rfc822 format available.

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

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 19099-done <at> debbugs.gnu.org,
 Rüdiger Sonderfeld <ruediger <at> c-plusplus.net>
Subject: Re: bug#19099: [PATCH] vc-git: Support `diff-switches'.
Date: Wed, 19 Nov 2014 12:13:14 +0100
tags 19099 fixed

On Tuesday 18 November 2014 23:36:11 Glenn Morris wrote:
> Thanks, works for me, and seems to neatly avoid being an incompatible
> change wrt vc-git-diff-switches being non-nil and non-t.

I've pushed it to master.

> BTW, I appreciate how you often try to improve git-related things.

Thanks!

Regards,
Rüdiger





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Wed, 19 Nov 2014 18:31:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
Cc: 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: [PATCH] vc-git: Support `diff-switches'.
Date: Wed, 19 Nov 2014 13:30:13 -0500
Thanks.
FWIW, you used a non-standard markup in the ChangeLog and commit log:
"Fix bug#19099" rather than "(Bug#19099)" and "Fixes: debbugs:19099".

(Ties back in to
http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg01024.html )




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Wed, 19 Nov 2014 19:06:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: ruediger <at> c-plusplus.de, 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: [PATCH] vc-git: Support `diff-switches'.
Date: Wed, 19 Nov 2014 21:05:33 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Wed, 19 Nov 2014 13:30:13 -0500
> Cc: 19099 <at> debbugs.gnu.org
> 
> FWIW, you used a non-standard markup in the ChangeLog and commit log:
> "Fix bug#19099" rather than "(Bug#19099)" and "Fixes: debbugs:19099".

I didn't understand the "Fixes: debbugs:19099" part was a decision.
It sounded like some discussion with no conclusion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19099; Package emacs. (Wed, 19 Nov 2014 19:45:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ruediger <at> c-plusplus.de, 19099 <at> debbugs.gnu.org
Subject: Re: bug#19099: [PATCH] vc-git: Support `diff-switches'.
Date: Wed, 19 Nov 2014 14:44:29 -0500
Eli Zaretskii wrote:

>> FWIW, you used a non-standard markup in the ChangeLog and commit log:
>> "Fix bug#19099" rather than "(Bug#19099)" and "Fixes: debbugs:19099".
>
> I didn't understand the "Fixes: debbugs:19099" part was a decision.
> It sounded like some discussion with no conclusion.

I agree with both your points.

The standard practice for ChangeLogs is not really in doubt, IMO
(modulo minor cosmetic details).

I'd really like there to be a standard for both, so I hope you push
through with that discussion and get it to a conclusion.
I don't really care what the standard is, so much as there is one.
I don't think I have the enthusiasm to help get it done right now.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 18 Dec 2014 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 242 days ago.

Previous Next


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