5 ms·
You can write a script (in Bash, Python, Go, whatever) that accepts the arguments passed by git (filenames for $BASE, $LOCAL, $REMOTE, and $MERGED)[1] and launc
by alexhutcheson 7y ago
You can write a script (in Bash, Python, Go, whatever) that accepts the arguments passed by git (filenames for $BASE, $LOCAL, $REMOTE, and $MERGED)[1] and launches whatever diff tool you'd like to use. You can then tell git to use it by setting the merge.tool and merge.tool.cmd configuration variables.
If you want to invoke different tools for different types of files, you can either handle this in your script, or you can explicitly pass the --tool flag in cases where you want to use a non-default tool.
Writing the wrapper script is generally pretty straightforward - the only "gotchas" are making sure the file patterns can be handled by your merge tool, and making sure you write the result to $MERGED. Sometimes you need to have a "clean-up" step in your script that copies the merge tool output to $MERGED and maybe deletes tmp files that were created.
[1] https://git-scm.com/docs/git-mergetool https://git-scm.com/docs/git-mergetool
- bluGill 7y agoThat doesn't help when the file is a binary and nobody has written a tool to merge it. How do you merge a picture?
- naikrovek 7y agoYou're not replying to me, but I imagine you'd decode both images to an uncompressed format and diff them visually, optionally with a way to highlight pixels that differ between the two. Binary file types that you can't view in some way would be challenging.
- jacobush 7y agoJPEG doesn't really have pixels though, and with some modern formats it gets even worse. For netlists it's hopeless.