
GIT - Using mcdiff as an external DIFF utility
- Tutorial
mcdiff
As part of Midnight Commander, in addition to the well-known mcedit editor, there is no less remarkable utility for comparing side-by-side files (mcdiff). It can be compared and, if necessary, to produce a full or partial merger in both directions.

The mcdif utility once once told the story here but closer to the point ...
Connect mcdiff to git
In order to use mcdiff together with git, you need to write a script - a diff_wrapper wrapper with the following contents
#!/bin/sh
/usr/bin/mcdiff "$1" "$2"
then save it. for example, in the ~ / bin / directory (or in any place convenient for you) without forgetting to give execution rights
chmod +x ~/bin/diff_wrapper
Next, you need to configure the wrapper call when you run the git diff command in the .gitconfig file .
my .gitconfig file contains the following lines
[diff]
external = /home/holmes/bin/diff_wrapper
[pager]
diff =
- external key indicates which external utility the data will be transferred
- the diff key in the pager section indicates which page viewer the contents of the output will be flipped through, and since The mcdiff utility takes control of everything, then the diff key must be reset, if this is not done, you can get a bunch of side effects.
by adding the -w option, you can disable the display of differences in whitespace
git diff -w
however, mcdiff itself can take care of this, just press F9 and select the option you need. In addition, other comparison options are available:
[x] Ignore case
[x] Ignore tabs
[x] Ignore changes to spaces
[x] Ignore all spaces
[x] Do not consider line feeds
In addition, if you need to refuse to run an external comparison utility, you must add the --no-ext-diff switch :
git diff --no-ext-diff
And of course, what I always use is the function of partial file merging, the F5 key in mcdiff.
NB: It is worth noting that an external comparison utility will be launched for each file changed in the commit, this is not always convenient, but there is nothing to be done, especially if there are a lot of files.
Additional information can be found on the official git
PS manual page : Let me know if you find typos in the text or want to add something to this note ...