📜 ⬆️ ⬇️

GIT - Using mcdiff as an external DIFF utility

mcdiff


In addition to the well-known mcedit editor, Midnight Commander has at least a great utility for comparing files side by side (side-by-side) - mcdiff. It can be compared and, if necessary, to produce a full or partial merger in both directions.



The history of the emergence of the utility mcdif was once told here but more to the point ...
')

Connect mcdiff to git


In order to use mcdiff with git you need to write a script wrapper diff_wrapper with the following contents

#!/bin/sh /usr/bin/mcdiff "$1" "$2" 

then save it. for example, in the ~ / bin / directory (or in any convenient place for you) without forgetting to give the execution rights
 chmod +x ~/bin/diff_wrapper 

Next, you need to configure the wrapper call when executing the git diff command in the .gitconfig file.

my .gitconfig file contains the following lines
 [diff] external = /home/holmes/bin/diff_wrapper [pager] diff = 



Also, by adding the -w option, you can disable the display of differences in whitespace characters.
 git diff -w 

however, mcdiff can take care of this itself, just press F9 and select the desired option. In addition, other comparison options are available:
[x] Ignore case
[x] Ignore tabs
[x] Ignore changes in spaces
[x] Ignore all spaces
[x] Disregard line breaks

In addition, if you need to refuse to run the external comparison utility, you must add the key - no-ext-diff :
 git diff --no-ext-diff 

And of course, what I use all the time is the function of partial merging of files, the F5 key in mcdiff.

NB: It should be noted that the external comparison utility will be launched for each file changed in a commit, this is not always convenient, but there is nothing to be done, especially if there are a lot of files.

More information can be found on the official git manual page.

PS: Let me know if you find typos in the text or want to add something to this note ...

Source: https://habr.com/ru/post/209400/


All Articles