Skip to content

git difftool -d/--dir-diff not working for kdiff3 or p4merge #4367

@KevinHake

Description

@KevinHake
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.39.2.windows.1
cpu: x86_64
built from commit: a82fa99b36ddfd643e61ed45e52abe314687df67
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19045.2604]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Rebase
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Enabled
Enable FSMonitor: Enabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

My .gitconfig contains the following:

[diff]
	tool = kdiff3
[difftool]
	prompt = true
	keepBackup = false
	trustExitCode = false
[difftool "p4merge"]
	path = C:/Program Files/Perforce/p4merge.exe
[difftool "kdiff3"]
	path = C:/Program Files/KDiff3/bin/kdiff3.exe

[merge]
	tool = kdiff3
[mergetool]
	prompt = true
	keepBackup = false
	keepTemporaries = false
[mergetool "p4merge"]
	path = C:/Program Files/Perforce/p4merge.exe
[mergetool "kdiff3"]
	path = C:/Program Files/KDiff3/bin/kdiff3.exe

I have kdiff3 1.9.6 from https://download.kde.org/stable/kdiff3/
I have p4merge 2023 March 16, Rev. P4Merge/NTX64/2023.1/2419860 from https://www.perforce.com/products/helix-core-apps/merge-diff-tool-p4merge (just got the latest)

Details

  • Which terminal/shell are you running Git from?
    Bash

  • What commands did you run to trigger this issue? If you can provide a
    Minimal, Complete, and Verifiable example
    this will help us understand the issue.

Summary - git difftool -d with p4merge or kdiff3 set as default in a repo with local changes.
Step by step:

  1. Install kdiff3 and p4merge, and add the above to your .gitconfig (where the paths point to where they were installed).
  2. Create a repo in a diff state in git bash (tho any should do):
mkdir -p /tmp/example
cd /tmp/example
git init .
echo Hello > a.txt
echo Derp > b.txt
mkdir mydir
touch mydir/c.txt
git add *
git commit -m "initial test files"
echo World! >> a.txt
echo 123 > mydir/c.txt

Check that both kdiff3 and p4merge work normally, without the --dir-diff option, to be sure you have them installed and configured correctly in git - these should prompt for the two files changed and properly show diffs in kdiff3 and p4merge, respectfully:

git difftool
git difftool --tool=p4merge
  1. Run the git directory diff:
git difftool -d
git difftool --dirdiff
git difftool -d --tool=p4merge
git difftool --dirdiff --tool=p4merge
  • What did you expect to occur after running these commands?

I expected to see a directory diff against a dir with original files and a dir with my local changes (kdiff3 for the first two commands, p4merge for the last 2).

  • What actually happened instead?

In Kdiff3 Operation column says "Error: Conflicting File Types" next to the changed files, and upon double-clicking one of them, the contents of only one side of the diff are displayed correctly, and in the other it shows an empty file.
In this example, double clicking mydir/c.txt says incorrectly it is binary equal (because the original copy is an empty file but the local version is not), and a.txt shows the "Hello" text on the left but no text on the right when it should have World! appended.

p4merge gives the following error:

Errors: 
'C:\Users\derpton\AppData\Local\Temp/git-difftool.a31052/left/' is (or points to) an invalid file.
'C:\Users\derpton\AppData\Local\Temp/git-difftool.a31052/right/' is (or points to) an invalid file

At first I thought this was a Kdiff3 issue, and there's a setting "Follow file links" and "Follow folder links" but all combinations of those settings didn't fix things for me. After realizing p4merge also isn't happy I am thinking git should probably be doing something differently here.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Happens in any repo I've tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions