CREDIT:
All of this was @Joachim's idea, in his comment to my question, above.
The detail of how to actually achieve this was mainly drawn from here: https://blog.beardhatcode.be/2018/03/your-own-git-mergetool.html, which offered a lot of insight into what the "command interface" for the merge script looks like.
As per @Joachim's suggestion, you can achieve this by wrapping up the kdiff exe in your own script, which also does the post-merge op, and then setting that as the mergetool.
The full gory details of a solution that implements this can be find in my Github:
https://github.com/Brondahl/AzureAdfDataflowGitPrettifier
The most interesting files are:
As a whole that is a solution for (losslessly) prettifying all instances of a certain filetype in my repository before every diff or comparison operation, and then (again losslessly) uglifying it again after any write operations that use this prettified version ... which in practice is just the kdiff3 merge.
The most crtical and subject-specific steps in there are probably:
In the kdiff-wrapping bash script:
kdiffPath=$(git config --get mergetool.kdiff3.path)
in order to get the current kdiff path.
applyPreProcessorConfig="PreProcessorCmd=.\\dataflowGitDiffTool\\AdfDataflowFilePrettifier.exe -prettify -fromStdIn"
which we'll pass to kdiff when invoking it, to tell it to use the prettifier
invokeKDiff=("$kdiffPath" "$@" "--cs" "$applyPreProcessorConfig")
followed by "${invokeKDiff[@]}"
in order to successfully pass all the args from the script ($@
) along to kdiff.
mergeOutput=$5
in order to know where the now-prettified, post-merge output file is which we should be uglifying.
And then the following to configure my git config to use the script appropriately:
git config merge.tool kdiff3_with_uglification
git config mergetool.keepBackup false
git config mergetool.kdiff3_with_uglification.cmd './dataflowGitDiffTool/kdiff3_with_uglification.sh "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"'
which produces a .git\config
file that looks like this:
[merge]
tool = kdiff3_with_uglification
[mergetool]
keepBackup = false
[mergetool "kdiff3_with_uglification"]
cmd = ./dataflowGitDiffTool/kdiff3_with_uglification.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"