Bug 410962

Summary: kdiff3 vs svn (subversion)
Product: [Applications] kdiff3 Reporter: Rob Brown <brown>
Component: applicationAssignee: michael <reeves.87>
Status: RESOLVED FIXED    
Severity: normal CC: turtle
Priority: NOR    
Version: 1.8.x   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 1.8.2
Sentry Crash Report:

Description Rob Brown 2019-08-15 23:50:20 UTC
SUMMARY
The command line sent to kdiff3 by svn used to work. Now it doesn't. The command line from svn is apparently:
  kdiff3 -u -L "filename (revision n)" -L "filename (revision m)" /tmp/svn-mumble /tmp/svn-mumble

STEPS TO REPRODUCE
1. create or find some useful text file for testing, such as fox.txt
2. in the shell, type
  kdiff3 -u -L "Left" -L "Right" fox.txt fox.txt

OBSERVED RESULT
  From 1.7.90, a three-way diff of Left, Right, and fox.txt, and complaints that it cannot open Left and Right.
  From 1.8.1, a Severe Internal Error: "Data loss error: If is it reproducible please contact the author."

EXPECTED RESULT
a two-way diff of fox.txt and fox.txt, the two files labelled "Left" and  "Right" (naturally showing no differences). This is what we saw with kdiff3 0.9.98.


SOFTWARE/OS VERSIONS
Kubuntu 19.04, which has 1.7.90. Also loaded the 1.8.1 package from Kubuntu 19.10.

ADDITIONAL INFORMATION
Comment 1 Turtle 2019-09-01 19:08:07 UTC
I can confirm this bug in 1.8, as a workaround call this
shell script from svn.
#!/bin/sh
kdiff3 --base "$6" "$7" --output "$7"
Comment 2 Turtle 2019-09-09 18:42:04 UTC
I did some poking around and this is defiantly something to do with the newer QT port.
In main.cpp just after
initialiseCmdLineArgs(cmdLineParser);
    // ignorable command options
There are some calls like:
    cmdLineParser->addOption(QCommandLineOption(QStringList() << QLatin1String("m") << QLatin1String("merge"), i18n("Merge the input.")));

Then some calls to add the files:
    cmdLineParser->addPositionalArgument(QLatin1String("[File1]"), i18n("file1 to open (base, if not specified via --base)"));
    cmdLineParser->addPositionalArgument(QLatin1String("[File2]"), i18n("file2 to open"));
    cmdLineParser->addPositionalArgument(QLatin1String("[File3]"), i18n("file3 to open"));

However the options seem to be clobbering the files, so my guess is another cmdLineParser needs to loop for every option that == 'L'
Comment 3 michael 2019-09-15 22:57:29 UTC
Looks I made mistake in translating to QCommandLineParser's API. Will push a fix shortly.
Comment 4 michael 2019-09-16 00:14:02 UTC
Git commit b7b2375c01b19ee1a1c49725fa28b0fa549156b4 by Michael Reeves.
Committed on 16/09/2019 at 00:05.
Pushed by mreeves into branch 'master'.

Fix '-L' parameter handling
FIXED-IN:1.8.2

M  +1    -1    src/kdiff3.cpp
M  +1    -1    src/main.cpp

https://invent.kde.org/kde/kdiff3/commit/b7b2375c01b19ee1a1c49725fa28b0fa549156b4
Comment 5 michael 2019-09-16 00:17:06 UTC
Git commit b4b2c97004b9df2ad9807ba5ac00bb8f06958ce5 by Michael Reeves.
Committed on 15/09/2019 at 22:58.
Pushed by mreeves into branch '1.8'.

Fix '-L' parameter handling
FIXED-IN:1.8.2

M  +1    -1    src/kdiff3.cpp
M  +1    -1    src/main.cpp

https://invent.kde.org/kde/kdiff3/commit/b4b2c97004b9df2ad9807ba5ac00bb8f06958ce5
Comment 6 Rob Brown 2019-09-19 01:34:36 UTC
I cloned and built. The resulting executable properly handles the -L options.  Looks good.  I'll look forward to this getting into the next release.  Thanks.

- - -

Some off-topic observations:

1.  The INSTALL file says "cmake && make".  This didn't work for me.  I eventually found that "cmake . && make" worked.

2.  I have no idea if this is expected, or if it is my environment, but the "cmake . && make" command produced 1681 lines of output, including 218 warnings (apparently 1 from cmake and 217 from make) and 214 "... is deprecated".