'How to set up a flatpak version of Meld as git mergetool?

Installing Meld as a regular Linux package, it is fairly straighforward to setup Meld as git merge tool, here is an extract of my .gitconfig.

[merge]
  tool = meld
[mergetool "meld"]
  trustExitCode = true
  cmd = meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"

But what about the flatpak version of Meld which you cannot execute simply with the command meld? I guess the cmd part should be something like

cmd = flatpak run org.gnome.meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"

but this exact command doesn't work. How should it be modified?



Solution 1:[1]

After going through this process today, I figured I would share my final working solution for a 3-way merge. It is based on the possible translation from VonC above.

[merge]
  tool = meld_flatpak

[mergetool "meld_flatpak"]
  cmd = flatpak run --file-forwarding org.gnome.meld \"@@\" $LOCAL \"@@\" \"@@\" $BASE \"@@\" \"@@\" $REMOTE \"@@\" --output \"@@\" $MERGED \"@@\"

[mergetool]
  prompt = false
  keepBackup = false
  writeToTemp = true

Solution 2:[2]

Check if this is similar to flatpak issue 1423:

You need the following command:

My .gitconfig:

[diff]
    tool = meld_flatpak


[difftool "meld_flatpak"]
    cmd = flatpak run --file-forwarding org.gnome.meld \"@@\" $LOCAL \"@@\" \"@@\" $REMOTE \"@@\"


[difftool]
    prompt = false

A possible translation for mergetool (considering the syntax for meld):

cmd = flatpak run --file-forwarding org.gnome.meld $LOCAL \"@@\" $BASE \"@@\" $REMOTE \"@@\" --output=$MERGED \"@@\""

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mike
Solution 2 koko