dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
23.04k stars 382 forks source link

svn diff is not supported #105

Open Yanpas opened 4 years ago

Yanpas commented 4 years ago

svn diff | delta

Delta behaves as less.

Does it support plain diff format?

dandavison commented 4 years ago

Hi @Yanpas, it does support unified diff format diff -u automatically.

No-one has worked yet on adding support for svn diff output. A helpful starting point might be to post some example output, or a script that creates an svn repo and generates example output. (I'm not familiar with subversion).

Yanpas commented 4 years ago

Here it is:

$ svn diff 
Index: file.c
===================================================================
--- file.c      (revision 14)
+++ file.c      (working copy)
@@ -1 +1,4 @@
-void aa(){}
+void ab(){}
+
+
+int aaa
$ svn diff -r 11 .
Index: f1
===================================================================
--- f1  (revision 11)
+++ f1  (working copy)
@@ -1 +1,4 @@
 line1
+lnie2
+
+aaa
Index: file.c
===================================================================
--- file.c      (nonexistent)
+++ file.c      (working copy)
@@ -0,0 +1,4 @@
+void ab(){}
+
+
+int aaa;
$ svn diff ^/branches/b1 ^/trunk
Index: f1
===================================================================
--- f1  (.../branches/b1)       (revision 14)
+++ f1  (.../trunk)     (revision 14)
@@ -1 +1,4 @@
 line1
+lnie2
+
+aaa
Index: file.c
===================================================================
--- file.c      (.../branches/b1)       (nonexistent)
+++ file.c      (.../trunk)     (revision 14)
@@ -0,0 +1 @@
+void aa(){}
Yanpas commented 4 years ago

I thought svn uses the same diff format as unified diff. Since it works with colordiff utility

dandavison commented 4 years ago

Thanks! I've made a start on this in https://github.com/dandavison/delta/pull/106. It looks very similar to unified diff output, so it should be a small change. (If you are able to compile the rust code from the repo (cargo build) then testing that branch out would be very helpful. I've added one TODO in the PR already.)

Yanpas commented 4 years ago

Yep, will try it out on real svn repo

mellotanica commented 3 years ago

I worked around the problem by wrapping delta in a simple shell script and using it as an svn diff command:

~/.subversion/config:

[...]
[helpers]
### Set diff-cmd to the absolute path of your 'diff' program.
###   This will override the compile-time default, which is to use
###   Subversion's internal diff implementation.
# diff-cmd = diff_program (diff, gdiff, etc.)
diff-cmd= /home/mellotanica/.subversion/svndiff
[...]

~/.subversion/svndiff:

#!/bin/bash

# skip '-u -L nameA -l nameB'
shift 5

git -c delta.file-style="omit" -c delta.paging="never" diff --no-index $@
quinncomendant commented 2 years ago

I'm using delta 0.12.0 and it seems to support svn diff output correctly when run like this:

function svndiff { svn diff -x -w "$@" | delta | less -R; }