DiffPlug can be automatated using the dp
command line tool. The dp
included in DiffPlug 2 is not backward-compatible with DiffPlug 1.
Installation
Windows
dp.bat
lives in the DiffPlug installation directory. All you have to do is add this directory to your system path.
If it's not working as expected:
- open new cmd prompt
- run
where dp
- it should print the directory you just added
- if it doesn't, there is another folder earlier in the path with
dp
Mac
The dp
executable lives in the DiffPlug.app/Contents/Resources/dp
. To make it easily available everywhere, just run
sudo ln -s /Applications/DiffPlug.app/Contents/Resources/dp /usr/local/bin/dp
If it's not working as expected:
- open a new terminal
- run
which dp
- it should print
/usr/local/bin/dp
- then
ls -l /usr/local/bin/dp
- it should print
/Applications/DiffPlug.app/Contents/Resources/dp
It is fine to put DiffPlug.app
somewhere else besides /Applications
, just change the instructions appropriately.
Linux
The dp
executable lives in the <DiffPlug install directory>/dp
. To make it easily available everywhere, just run
sudo ln -s <DiffPlug install directory>/dp /usr/local/bin/dp
If it's not working as expected:
- open a new terminal
- run
which dp
- it should print
/usr/local/bin/dp
- then
ls -l /usr/local/bin/dp
- it should print
<DiffPlug install directory>/dp
General usage
dp
will connect to whichever instance of DiffPlug 2 was launched most recently.
To see what commands are available, simply run dp
at a console.
cmd> dp
You must specify a command.
usage: dp <command> [args ...]
'dp help <command>' for more info. Available commands:
add Adds the given paths to the palette
cat Dumps an entity's binary content to standard output
slurp Slurps standard input into the given entity
ext Integration with external vcs clients (open, diff, and merge)
To get help for a particular command, type dp help <command>
cmd> dp help ext
Integration with external vcs clients (open, diff, and merge)
usage: dp ext -before FILE [-after FILE] [-ours FILE] [-theirs FILE] [-result FILE]
-before FILE : base file
-after FILE : 2-way diff - file after change
-ours FILE : 3-way diff - file after our changes
-theirs FILE : 3-way diff - file after their changes
-result FILE : editiable version of file, converts diff to merge
<Further docs>
dpopen helper script
dp
is a general-purpose interface to DiffPlug - it's not just about opening files. However, "just open this file" is a common usecase, and sometimes you are not able to configure the arguments and flags necessary for dp
to open a file. For this purpose, there is the dpopen
helper script. It is actually an alias to dp ext -before <FILENAME>
, and it allows you to integrate DiffPlug with tools that don't accept configurable arguments.
Integrating with external tools using "dp ext"
One of dp ext
's features is that the dp
will remain running so long as the files it referenced are still open in DiffPlug. You can have multiple calls to dp ext
, and each will close at the appropriate time when you have stopped using those temporary files in DiffPlug.
This is especially important for comparing folders, and using DiffPlug as a conflict resolution tool.
Here are some quick integrations for common version control tools:
Tool | Cmd | More info |
---|---|---|
git difftool | dp ext -flavor git -before "$LOCAL" -beforeName "before:/$MERGED" -after "$REMOTE" -afterName "after:/$MERGED" -result "$MERGED" |
docs |
git mergetool | dp ext -flavor git -before "$BASE" -beforeName "before:/$MERGED" -ours "$LOCAL" -oursName "ours:/$MERGED" -theirs "$REMOTE" -theirsName "theirs:/$MERGED" -result "$MERGED" |
docs |
mercurial | dp ext -before $base -ours $local -theirs $other -result $output |
docs |
TortoiseSVN diff | dp ext -before %base -beforeName %bname -after %mine -afterName %yname |
docs |
TortoiseSVN merge | dp ext -before %base -beforeName %bname -ours %mine -oursName %yname -theirs %theirs -theirsName %tname -result %merged |
(see above) |
TortoiseHg
Set your ~/mercurial.ini
to be similar to the following:
[tortoisehg]
vdiff=diffplug2
[merge-tools]
diffplug2.executable = PATH_TO_EXTRACTED_FOLDER\dp.bat
diffplug2.args = ext -flavor tortoiseHg -before $base -ours $local -theirs $other -result $output
diffplug2.diffargs= ext -flavor tortoiseHg -before $parent -after $child -beforeName '$plabel1' -afterName '$clabel'
diffplug2.diff3args= ext -flavor tortoiseHg -before $parent1 -beforeName '$plabel1' -ours $child -oursName '$clabel' -theirs $parent2 -theirsName '$plabel2'
diffplug2.binary = true
diffplug2.symlink = false
diffplug2.gui = true
diffplug2.priority = 1
diffplug2.dirdiff=True
[merge-patterns]
**.slx = diffplug2
**.mdl = diffplug2
[ui]
diff = diffplug2
merge = diffplug2
git
If you set your ~/.gitconfig
to be similar to the following then the command-line and command-line based tools such as "Git Extensions" should work fine.
ESCAPING: Make sure to enter these lines in a text editor, not in the settings dialog of a gui client. Note that the "
are escaped as \"
below. Depending on the gui client, you may or may not need to enter the escape \
. The safest bet is to only use a regular text editor.
FOR WINDOWS USERS: You may need to change dp
to dp.bat
, depending on which shell you have configured with git.
[difftool "diffplug"]
path = <path to dp, only needed if dp is not on path>
cmd = dp ext -flavor git -before \"$LOCAL\" -beforeName \"before:/$MERGED\" -after \"$REMOTE\" -afterName \"after:/$MERGED\" -result \"$MERGED\"
[mergetool "diffplug"]
path = <path to dp, only needed if dp is not on path>
cmd = dp ext -flavor git -before \"$BASE\" -beforeName \"before:/$MERGED\" -ours \"$LOCAL\" -oursName \"ours:/$MERGED\" -theirs \"$REMOTE\" -theirsName \"theirs:/$MERGED\" -result \"$MERGED\"
[merge]
tool = diffplug
guitool = diffplug
[diff]
tool = diffplug
guitool = diffplug
Atlassian SourceTree
- From the menu bar, select
Tools -> Options
- In the
Diff
tab, setExternal Diff / Merge
to:- Diff Arguments:
ext -flavor git -before "$LOCAL" -beforeName "before:/$MERGED" -after "$REMOTE" -afterName "after:/$MERGED" -result "$MERGED"
- Merge Arguments:
ext -flavor git -before "$BASE" -beforeName "before:/$MERGED" -ours "$LOCAL" -oursName "ours:/$MERGED" -theirs "$REMOTE" -theirsName "theirs:/$MERGED" -result "$MERGED"
- Diff Arguments:
- Now, whenever you click a changed file, you can click the gear drop down and select
External Diff
to open the diff in DiffPlug. - NOTE: SourceTree will only allow one "External Diff" to happen at a time. You have to close the previous diff in DiffPlug before SourceTree will initiate a new diff.
TortoiseGit
- From windows explorer, right-click a repository, then select
TortoiseGit -> Settings
(it will be towards the bottom). - Select
Diff Viewer
in the left side pane- For "Configure the program used for comparing different revisions of files", select
External
then enter:<path to dp> ext -flavor tortoiseGitDiff -before %base -beforeName %bname -after %mine -afterName %yname -result %ypath
- Leave "Configure viewer program for GNU diff files (patch files)" alone
- For "Configure the program used for comparing different revisions of files", select
- Select
Merge Tool
in the left side pane- Enter the line:
<path to dp> ext -flavor tortoiseGitMerge -before %base -beforeName %bname -ours %mine -oursName %yname -theirs %theirs -theirsName %tname -result %merged
- Enter the line:
Perforce (Helix Client P4V)
- From the menu bar, select
Edit -> Preferences
. - Select
File Editors
in the left side pane- For any files you want to use DiffPlug to open, select
Add...
- For Application, enter the path to
dpopen
, notdp
, and be sure to checkAlways use the selected application to open files of this type
- For any files you want to use DiffPlug to open, select
- Select
Diff
in the left side pane- To use DiffPlug for all diffs, select
Other application
, or to use DiffPlug for only a specific filetype such as.mdl
or.slx
, clickAdd...
- Arguments:
ext -before %1 -after %2
- To use DiffPlug for all diffs, select
- Select
Merge
in the left side pane- To use DiffPlug for all merges, select
Other application
, or to use DiffPlug for only a specific filetype such as.mdl
or.slx
, clickAdd...
- Arguments:
ext -before %b -theirs %1 -ours %2 -result %r
- To use DiffPlug for all merges, select