What kind of tool you are ready to view the diff file?

I have a script which generates a diff as I need it (in a certain way commits are selected for comparison, specify the required settings). The result of the script I would like to display in the console and in a GUI.

That is, I need a tool that takes as input a ready diff file and just displays it. The main requirement is to share the diff files and display separately for each file. It is desirable to have syntax highlighting diff (so that the deleted lines were distinguished from the added color, and not only familiar in the beginning). It is also very important to be able to copy text from the viewer, at least line by line.

I thought these tools a lot. However, after going through almost all the utilities from the list issued on my platform command git difftool --tool-help, was able to locate only mode in the program Kompare (cat data.diff | kompare -).

Unfortunately, Kompare does not support copying text, you can only watch. And writes it to the developer, this functionality does not appear — this requires to rewrite all the display.

Maybe there is some other alternative for this problem? Once again, I don't need a generator diff, you only need the viewer.

Platform: Linux (Kubuntu). But the best cross-platform, so you can run at least on Windows.

Example usage

Suppose I have the following diff-file named data.diff:

diff --unified -r foo-#1/bar/bar.md foo-#2/bar/bar.md
--- foo-#1/bar/bar.md 2016-04-30 00:04:13.176644057 +0300
+++ foo-#2/bar/bar.md 2016-04-30 00:03:51.864644969 +0300
@@ -1,7 +1,9 @@
 # Bar

 * record bar **#1**;
-* record bar **#2**;
+* the record bar **#2**:
+ * the record bar **#2.1**;
+ * the record bar **#2.2**;
 * record bar **#3**;
 * record bar **#4**;
 * record bar **#5**;
diff --unified -r foo-#1/baz/baz.md foo-#2/baz/baz.md
--- foo-#1/baz/baz.md 2016-04-30 00:04:07.152644315 +0300
+++ foo-#2/baz/baz.md 2016-04-30 00:03:48.048645132 +0300
@@ -3,6 +3,10 @@
 * baz record **#1**;
 * baz record **#2**;
 * baz record **#3**;
-* baz record **#4**;
+* baz record **#4**:
+ * baz record **#4.1**;
+ * baz record **#4.2**;
+ * baz record **#4.3**;
+ * baz record **#4.4**;
 * baz record **#5**;
 * baz record **#6**.


Run Kompare:

cat data.diff | kompare -

816c26570f984a9f8084e8d06f3fdfd0.png

Now run Midnight Commander (mc):

cd8bf39531854ce69bf361b726d7ba94.png

I launched it in the directory where data.diff, and then in the left tab I went inside a diff file like in directory (note the path in the left tab: data.diff/patchfs://foo-#1/bar).

Now open the virtual file changes only the file foo-#1/bar/bar:

fdef77609452476dac92aaba528c28a8.png

Thus we see that the programs share the diff file into pieces corresponding to the different files, display the tree of files and allow you to switch between them, looking at changes for each of them individually.

Again I will explain what I do not fit the above options:

  • Kompare does not allow you to copy text, you can only watch. Doesn't fit at all.
  • mc, in principle, suitable for all, but it's a console application. I would be much easier to use a GUI app.
July 12th 19 at 17:09
4 answers
July 12th 19 at 17:11
Solution
In mc you can go to .diff in the directory with the patches
Thank you so much, this is exactly what you need!

I would, of course, still a GUI app (at least because that is convenient for me the color theme of the console makes the text completely unreadable in mc), but this is quite possible to work. - ale commented on July 12th 19 at 17:14
July 12th 19 at 17:13
meld?
I have reviewed the program and found it, I need mode. It can compare files and directories, but does not allow you to access a ready diff. - ale commented on July 12th 19 at 17:16
July 12th 19 at 17:15
Any text editor with syntax highlighting (vim)
This is not an option because I need the split the diff on the files in it. So I can choose a specific file and view just the changes. - ale commented on July 12th 19 at 17:18
: search by file name does not fit? - ale commented on July 12th 19 at 17:21
: search is not suitable to work with long text file is still not as convenient as with a number of smaller ones. Moreover, in this case, it is problematic to evaluate the list of all changed files. - ale commented on July 12th 19 at 17:24
July 12th 19 at 17:17
> vim <src file></src>
after opening perform:
:vert diffpa <path to patch file>

either immediately from the command line:
> vim <src file> +'vert diffpa <path to patch file>'</src>


On Windows, haven't checked, but I assume that should work as well.
I truly understand that the src file is the main file and patch file the patch file (diff) to it? (Based on this description: vimdoc.sourceforge.net/htmldoc/diff.html#:diffpatch )

If so, then to me this is not an option. First, I have a diff file of the changes not one file but several. To view the diff I want for all of these files, just switching between them back and forth. Secondly, I have no original files, only ready-made diff with their changes. - ale commented on July 12th 19 at 17:20
Well, then maybe https://github.com/ymattw/cdiff to help you. - ale commented on July 12th 19 at 17:23
the only feature cdiff is mode support side by side (which I, by the way, is not necessary). A separate view changes in files no. - ale commented on July 12th 19 at 17:26
Something I then stopped to understand than the usual vim (vimdiff not) is not suitable. The background light is on, the text can be copied... you to Switch between file names, too, like once or twice. What does not fit? - Berta.Blan commented on July 12th 19 at 17:29
: I need to switch among those files described inside the diff file. The same changes to multiple files are listed one by one, specifying the original file name. Thus within these files (and even directories, which specify what they are) on the drive may not be (for example, if diff has been brought from outside).

That is, I need to split diff into pieces corresponding to the different files, showed me the tree of files and allow to switch between them, looking at changes for each of them individually.

I have described Kompare and suggested Midnight Commander (mc) allow exactly this. They represent a single diff file in the virtual file system (so to speak), where instead of each of the files are separate diff files for them.

vim displays the same diff just as a simple text file, just highlighting the diff syntax in it. Perhaps it is my desired mode, but I don't know how to turn it on and I would be grateful if you advise me.

Added in the question an example of a diff file and screenshot of what I want to. - ale commented on July 12th 19 at 17:32

Find more questions by tags Data comparisonSoftwareGit