All of lore.kernel.org
 help / color / mirror / Atom feed
* difftool sends malformed path to exernal tool on Windows
@ 2014-02-17 22:14 Paul Lotz
  2014-02-21 10:38 ` David Aguilar
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Lotz @ 2014-02-17 22:14 UTC (permalink / raw)
  To: git

From the Git Bash command line, I enter
$ git difftool

and type ‘y’ when the file I want to difference appears.  Git correctly
calls the external diff tool (LVCompare.exe), but the path for the remote
file Git passes to that tool is malformed (e.g.,
C:\/Users/Paul/AppData/Local/Temp/QCpqLa_calcLoadCellExcitation.vi). 
Obviously the \/ (backslash forwardslash) combination is incorrect.

For the record, I have successfully made calls to LVCompare.exe manually
from a Windows command prompt directly (without Git).

The relevant portion of the .gitconfig file is:
[diff]
     tool = "LVCompare"
[difftool "LVCompare"]
     cmd = 'C:/Program Files (x86)/National Instruments/Shared/LabVIEW
Compare/LVCompare.exe' \"$LOCAL\"  \"$REMOTE\"


For the record, the operating system is Windows 8.1.

Paul

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: difftool sends malformed path to exernal tool on Windows
  2014-02-17 22:14 difftool sends malformed path to exernal tool on Windows Paul Lotz
@ 2014-02-21 10:38 ` David Aguilar
  2014-02-24 16:44   ` Paul Lotz
  2014-02-28 15:56   ` Paul Lotz
  0 siblings, 2 replies; 10+ messages in thread
From: David Aguilar @ 2014-02-21 10:38 UTC (permalink / raw)
  To: Paul Lotz; +Cc: git

On Mon, Feb 17, 2014 at 03:14:01PM -0700, Paul Lotz wrote:
> From the Git Bash command line, I enter
> $ git difftool
> 
> and type ‘y’ when the file I want to difference appears.  Git correctly
> calls the external diff tool (LVCompare.exe), but the path for the remote
> file Git passes to that tool is malformed (e.g.,
> C:\/Users/Paul/AppData/Local/Temp/QCpqLa_calcLoadCellExcitation.vi). 
> Obviously the \/ (backslash forwardslash) combination is incorrect.

If this is the case then difftool is not the only one with this problem.

We use the GIT_EXTERNAL_DIFF mechanism to run difftool under "git diff",
so it may be that the paths are mangled by "git diff" itself.
I don't really know enough about msysgit to know for sure, though.

What do you see if you create a dummy tool which just does "echo"?

[difftool "test"]
	cmd = echo \"$LOCAL\" \"$REMOTE\"

Then run:

$ git difftool -t test

> For the record, I have successfully made calls to LVCompare.exe manually
> from a Windows command prompt directly (without Git).
> 
> The relevant portion of the .gitconfig file is:
> [diff]
>      tool = "LVCompare"
> [difftool "LVCompare"]
>      cmd = 'C:/Program Files (x86)/National Instruments/Shared/LabVIEW
> Compare/LVCompare.exe' \"$LOCAL\"  \"$REMOTE\"
> 
> 
> For the record, the operating system is Windows 8.1.

Do any msysgit folks know whether GIT_EXTERNAL_DIFF is a known issue?
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: difftool sends malformed path to exernal tool on Windows
  2014-02-21 10:38 ` David Aguilar
@ 2014-02-24 16:44   ` Paul Lotz
  2014-03-03  0:35     ` David Aguilar
  2014-02-28 15:56   ` Paul Lotz
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Lotz @ 2014-02-24 16:44 UTC (permalink / raw)
  To: 'David Aguilar'; +Cc: git

David,

Thanks for the helpful reply.

As you suggested, I modified the .gitconfig file to have:
[difftool "test"]
	cmd = echo \"$LOCAL\" \"$REMOTE\"

and ran
$ git difftool -t test

An example of the the resulting console output is:
C:/Users/Paul/AppData/Local/Temp/I8L2Bc_WriteTestParameters.vi Commands/StartAutomatedTest/WriteTestParameters.vi

Paul

-----Original Message-----
From: David Aguilar [mailto:davvid@gmail.com] 
Sent: Friday, February 21, 2014 3:38 AM
To: Paul Lotz
Cc: git@vger.kernel.org
Subject: Re: difftool sends malformed path to exernal tool on Windows

On Mon, Feb 17, 2014 at 03:14:01PM -0700, Paul Lotz wrote:
> From the Git Bash command line, I enter $ git difftool
> 
> and type ‘y’ when the file I want to difference appears.  Git 
> correctly calls the external diff tool (LVCompare.exe), but the path 
> for the remote file Git passes to that tool is malformed (e.g., 
> C:\/Users/Paul/AppData/Local/Temp/QCpqLa_calcLoadCellExcitation.vi).
> Obviously the \/ (backslash forwardslash) combination is incorrect.

If this is the case then difftool is not the only one with this problem.

We use the GIT_EXTERNAL_DIFF mechanism to run difftool under "git diff", so it may be that the paths are mangled by "git diff" itself.
I don't really know enough about msysgit to know for sure, though.

What do you see if you create a dummy tool which just does "echo"?

[difftool "test"]
	cmd = echo \"$LOCAL\" \"$REMOTE\"

Then run:

$ git difftool -t test

> For the record, I have successfully made calls to LVCompare.exe 
> manually from a Windows command prompt directly (without Git).
> 
> The relevant portion of the .gitconfig file is:
> [diff]
>      tool = "LVCompare"
> [difftool "LVCompare"]
>      cmd = 'C:/Program Files (x86)/National Instruments/Shared/LabVIEW 
> Compare/LVCompare.exe' \"$LOCAL\"  \"$REMOTE\"
> 
> 
> For the record, the operating system is Windows 8.1.

Do any msysgit folks know whether GIT_EXTERNAL_DIFF is a known issue?
--
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: difftool sends malformed path to exernal tool on Windows
  2014-02-21 10:38 ` David Aguilar
  2014-02-24 16:44   ` Paul Lotz
@ 2014-02-28 15:56   ` Paul Lotz
  1 sibling, 0 replies; 10+ messages in thread
From: Paul Lotz @ 2014-02-28 15:56 UTC (permalink / raw)
  To: 'David Aguilar'; +Cc: git

OK, so what can we do next?

Paul

-----Original Message-----
From: Paul Lotz [mailto:plotz@lsst.org] 
Sent: Monday, February 24, 2014 9:44 AM
To: 'David Aguilar'
Cc: 'git@vger.kernel.org'
Subject: RE: difftool sends malformed path to exernal tool on Windows

David,

Thanks for the helpful reply.

As you suggested, I modified the .gitconfig file to have:
[difftool "test"]
	cmd = echo \"$LOCAL\" \"$REMOTE\"

and ran
$ git difftool -t test

An example of the the resulting console output is:
C:/Users/Paul/AppData/Local/Temp/I8L2Bc_WriteTestParameters.vi Commands/StartAutomatedTest/WriteTestParameters.vi

Paul

-----Original Message-----
From: David Aguilar [mailto:davvid@gmail.com]
Sent: Friday, February 21, 2014 3:38 AM
To: Paul Lotz
Cc: git@vger.kernel.org
Subject: Re: difftool sends malformed path to exernal tool on Windows

On Mon, Feb 17, 2014 at 03:14:01PM -0700, Paul Lotz wrote:
> From the Git Bash command line, I enter $ git difftool
> 
> and type ‘y’ when the file I want to difference appears.  Git 
> correctly calls the external diff tool (LVCompare.exe), but the path 
> for the remote file Git passes to that tool is malformed (e.g., 
> C:\/Users/Paul/AppData/Local/Temp/QCpqLa_calcLoadCellExcitation.vi).
> Obviously the \/ (backslash forwardslash) combination is incorrect.

If this is the case then difftool is not the only one with this problem.

We use the GIT_EXTERNAL_DIFF mechanism to run difftool under "git diff", so it may be that the paths are mangled by "git diff" itself.
I don't really know enough about msysgit to know for sure, though.

What do you see if you create a dummy tool which just does "echo"?

[difftool "test"]
	cmd = echo \"$LOCAL\" \"$REMOTE\"

Then run:

$ git difftool -t test

> For the record, I have successfully made calls to LVCompare.exe 
> manually from a Windows command prompt directly (without Git).
> 
> The relevant portion of the .gitconfig file is:
> [diff]
>      tool = "LVCompare"
> [difftool "LVCompare"]
>      cmd = 'C:/Program Files (x86)/National Instruments/Shared/LabVIEW 
> Compare/LVCompare.exe' \"$LOCAL\"  \"$REMOTE\"
> 
> 
> For the record, the operating system is Windows 8.1.

Do any msysgit folks know whether GIT_EXTERNAL_DIFF is a known issue?
--
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: difftool sends malformed path to exernal tool on Windows
  2014-02-24 16:44   ` Paul Lotz
@ 2014-03-03  0:35     ` David Aguilar
  2014-03-03 23:24       ` Paul Lotz
  0 siblings, 1 reply; 10+ messages in thread
From: David Aguilar @ 2014-03-03  0:35 UTC (permalink / raw)
  To: Paul Lotz; +Cc: Git Mailing List

On Mon, Feb 24, 2014 at 8:44 AM, Paul Lotz <plotz@lsst.org> wrote:
> David,
>
> Thanks for the helpful reply.
>
> As you suggested, I modified the .gitconfig file to have:
> [difftool "test"]
>         cmd = echo \"$LOCAL\" \"$REMOTE\"
>
> and ran
> $ git difftool -t test
>
> An example of the the resulting console output is:
> C:/Users/Paul/AppData/Local/Temp/I8L2Bc_WriteTestParameters.vi Commands/StartAutomatedTest/WriteTestParameters.vi

Hmm. That's interesting.

The next test: replace "echo" with "cat".

Are the contents of both files printed?

If so, then the next thing to try is running:

LVCompare.exe [same paths printed by echo]

and then seeing if it does the right thing.

Could it be that LVCompare.exe is getting tripped up by the forward slashes?

I'm not familiar enough with how msysgit mangles paths before
launching programs. It may be that the C:/foo/bar/baz path is getting
manged (that's my current guess), but I really don't know.

Another tip I've read online is that launching git via "cmd.exe" may
avoid the path mangling. Sorry I'm not more helpful in this area.

Another workaround you can do is to place a shell script wrapper
around LVCompare.exe that replaces C:\/ with / and then launches the
real LVCompare.exe; that's a workaround, but it could work.

I hope that helps shed some light on what may be going on.
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: difftool sends malformed path to exernal tool on Windows
  2014-03-03  0:35     ` David Aguilar
@ 2014-03-03 23:24       ` Paul Lotz
  2014-03-05  8:25         ` David Aguilar
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Lotz @ 2014-03-03 23:24 UTC (permalink / raw)
  To: 'David Aguilar'; +Cc: 'Git Mailing List'

David,

OK, I did as you suggested, and the results were revealing.

First, I replaced "echo" with "cat".  Result: The contents of both files appeared in the Git Bash Window.

Then I tried calling LVCompare from the Git Bash and Windows Command Prompt windows with variations on the paths.

Here are the most relevant results:
First from the Windows Command Prompt:
1) This command works:
C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National Instruments\Shared\L
abVIEW Compare\LVCompare.exe" C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
us_Before.ctl C:\LSST_TS\SystemSW\M2AADT\Typedefs\TestStatus.ctl
[General note:
I saved a copy of the temp file and replaced the hex string with the string 'Before' to make the file stick around.  The paths are otherwise the same.]

2) C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National Instruments\Shared\L
abVIEW Compare\LVCompare.exe" C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
us_Before.ctl Typedefs\TestStatus.ctl

Result: Error message with reference to C:\Program Files (x86)\National Instruments\Shared\L
abVIEW Compare\supportVIs\_prolvcmp.llb\Typedefs\TestStatus.ctl

Observation: The second path has to be the full path, not the relative path we get back using "echo".

>From the Git Bash window:
1) I tried the command that worked in the Windows Command Prompt:
"C:\Program Files (x86)\National Instruments\Shared\L
abVIEW Compare\LVCompare.exe" C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
us_Before.ctl C:\LSST_TS\SystemSW\M2AADT\Typedefs\TestStatus.ctl

Result: Error message with reference to C:\UsersPaulAppDataLocalTempTypedefs_TestStatus_Before.ctl

2) So I tried a variation with forward slashes instead in the parameters:
"C:\Program Files (x86)\National Instruments\Shared\L
abVIEW Compare\LVCompare.exe" C:/Users/Paul/AppData/Local/Temp/Typedefs_TestStat
us_Before.ctl C:/LSST_TS/SystemSW/M2AADT/Typedefs/TestStatus.ctl

Result: Error message with reference to C:\/Users/Paul/AppData/Local/Temp/Typedefs_TestStatus_Before.ctl
[Note: This is the familiar problem we saw using the Git difftool command.]

3) So I tried forward slashes even in the LVCompare.exe path:
"C:/Program Files (x86)/National Instruments\Shared\L
abVIEW Compare\LVCompare.exe" C:/Users/Paul/AppData/Local/Temp/Typedefs_TestStat
us_Before.ctl C:/LSST_TS/SystemSW/M2AADT/Typedefs/TestStatus.ctl

Result: Error message with reference to C:\/Users/Paul/AppData/Local/Temp/Typedefs_TestStatus_Before.ctl

[No difference.]

Paul

-----Original Message-----
From: David Aguilar [mailto:davvid@gmail.com] 
Sent: Sunday, March 2, 2014 5:35 PM
To: Paul Lotz
Cc: Git Mailing List
Subject: Re: difftool sends malformed path to exernal tool on Windows

On Mon, Feb 24, 2014 at 8:44 AM, Paul Lotz <plotz@lsst.org> wrote:
> David,
>
> Thanks for the helpful reply.
>
> As you suggested, I modified the .gitconfig file to have:
> [difftool "test"]
>         cmd = echo \"$LOCAL\" \"$REMOTE\"
>
> and ran
> $ git difftool -t test
>
> An example of the the resulting console output is:
> C:/Users/Paul/AppData/Local/Temp/I8L2Bc_WriteTestParameters.vi 
> Commands/StartAutomatedTest/WriteTestParameters.vi

Hmm. That's interesting.

The next test: replace "echo" with "cat".

Are the contents of both files printed?

If so, then the next thing to try is running:

LVCompare.exe [same paths printed by echo]

and then seeing if it does the right thing.

Could it be that LVCompare.exe is getting tripped up by the forward slashes?

I'm not familiar enough with how msysgit mangles paths before launching programs. It may be that the C:/foo/bar/baz path is getting manged (that's my current guess), but I really don't know.

Another tip I've read online is that launching git via "cmd.exe" may avoid the path mangling. Sorry I'm not more helpful in this area.

Another workaround you can do is to place a shell script wrapper around LVCompare.exe that replaces C:\/ with / and then launches the real LVCompare.exe; that's a workaround, but it could work.

I hope that helps shed some light on what may be going on.
--
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: difftool sends malformed path to exernal tool on Windows
  2014-03-03 23:24       ` Paul Lotz
@ 2014-03-05  8:25         ` David Aguilar
  2014-03-05 22:28           ` Paul Lotz
  2014-03-07 16:07           ` Paul Lotz
  0 siblings, 2 replies; 10+ messages in thread
From: David Aguilar @ 2014-03-05  8:25 UTC (permalink / raw)
  To: Paul Lotz; +Cc: 'Git Mailing List'

On Mon, Mar 03, 2014 at 04:24:15PM -0700, Paul Lotz wrote:
> David,
> 
> OK, I did as you suggested, and the results were revealing.
> 
> First, I replaced "echo" with "cat".  Result: The contents of both files appeared in the Git Bash Window.
> 
> Then I tried calling LVCompare from the Git Bash and Windows Command Prompt windows with variations on the paths.
> 
> Here are the most relevant results:
> First from the Windows Command Prompt:
> 1) This command works:
> C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National Instruments\Shared\L
> abVIEW Compare\LVCompare.exe" C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl C:\LSST_TS\SystemSW\M2AADT\Typedefs\TestStatus.ctl
> [General note:
> I saved a copy of the temp file and replaced the hex string with the string 'Before' to make the file stick around.  The paths are otherwise the same.]

This is aligns with: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configlvcomp_thirdparty/

	"lvcompare.exe <absolute path to VI 1> ..."

The key thing is the mention of absolute paths.

What is happening is that lvcompare.exe (or likely it's a
Windows thing) changes its current directory to its installation
directory under Progra~1.

That means the relative paths passed in by difftool won't be found.

The way to fix it is to redirect your difftool config to a script
that makes all paths absolute.  This script can then call the real
lvcompare.exe.

You just need to tweak the lvcompare part in your .gitconfig
to look like this:

[difftool "lvcompare"]
	cmd = ~/bin/lvcompare.sh \"$LOCAL\" \"$REMOTE\"


... and install an executable lvcompare.sh shell script in in
your $HOME/bin.  Something like this:

#!/bin/sh

abspath () {
	(
		cd "$(dirname "$1")" &&
		printf "%s/%s" "$(pwd)" "$(basename "$1")"
	)
}

lvcompare="C:\\Program Files (x86)\National Instruments\\Shared\\LabVIEW Compare\\LVCompare.exe"
local=$(abspath "$1")
remote=$(abspath "$2")
exec "$lvcompare" "$local" "$remote"

> 2) C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National Instruments\Shared\L
> abVIEW Compare\LVCompare.exe" C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl Typedefs\TestStatus.ctl
> 
> Result: Error message with reference to C:\Program Files (x86)\National Instruments\Shared\L
> abVIEW Compare\supportVIs\_prolvcmp.llb\Typedefs\TestStatus.ctl
> 
> Observation: The second path has to be the full path, not the relative path we get back using "echo".

Yes, that's what it looks like.
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: difftool sends malformed path to exernal tool on Windows
  2014-03-05  8:25         ` David Aguilar
@ 2014-03-05 22:28           ` Paul Lotz
  2014-03-07 16:07           ` Paul Lotz
  1 sibling, 0 replies; 10+ messages in thread
From: Paul Lotz @ 2014-03-05 22:28 UTC (permalink / raw)
  To: 'David Aguilar'; +Cc: 'Git Mailing List'

David,

We did succeed in getting a script to work.  The local Git guru started with your script (he independently sent me something very similar) and added some tricks to make things work.

The contents of the shell script ended up as:
___
#!/bin/bash

# Method to determine absolute path
# The -W option on the pwd command is necessary to return the Windows version of the path.
# Leaving off the -W option will result in a conversion of temp directory to a Linux-specific 'tmp' path.
# Piping the result through tr '/' '\\' translates the forward slashes to backslashes.
# Windows understands forward slashes, but LVCompare.exe does not.
abspath () {
	(
		DIR=$(dirname "$1")
		FN=$(basename "$1")
		cd "$DIR"
		printf "%s/%s" "$(pwd -W)" "$FN" | tr '/' '\\'
	)
}

lvcompare="C:\\Program Files (x86)\National Instruments\\Shared\\LabVIEW Compare\\LVCompare.exe"
local=$(abspath "$1")
remote=$(abspath "$2")
exec "$lvcompare" -nobdpos -nofppos "$local" "$remote"
# For the options, see http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configlvcomp_thirdparty/.
___

This works, but the solution seems to me nontrivial.

I will post this solution in Git with LabVIEW threads tomorrow, but I thought I'd see if you have any suggestions before I do that.

Thanks much!

Paul

-----Original Message-----
From: David Aguilar [mailto:davvid@gmail.com] 
Sent: Wednesday, March 5, 2014 1:25 AM
To: Paul Lotz
Cc: 'Git Mailing List'
Subject: Re: difftool sends malformed path to exernal tool on Windows

On Mon, Mar 03, 2014 at 04:24:15PM -0700, Paul Lotz wrote:
> David,
> 
> OK, I did as you suggested, and the results were revealing.
> 
> First, I replaced "echo" with "cat".  Result: The contents of both files appeared in the Git Bash Window.
> 
> Then I tried calling LVCompare from the Git Bash and Windows Command Prompt windows with variations on the paths.
> 
> Here are the most relevant results:
> First from the Windows Command Prompt:
> 1) This command works:
> C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National 
> Instruments\Shared\L abVIEW Compare\LVCompare.exe" 
> C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl C:\LSST_TS\SystemSW\M2AADT\Typedefs\TestStatus.ctl
> [General note:
> I saved a copy of the temp file and replaced the hex string with the 
> string 'Before' to make the file stick around.  The paths are 
> otherwise the same.]

This is aligns with: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configlvcomp_thirdparty/

	"lvcompare.exe <absolute path to VI 1> ..."

The key thing is the mention of absolute paths.

What is happening is that lvcompare.exe (or likely it's a Windows thing) changes its current directory to its installation directory under Progra~1.

That means the relative paths passed in by difftool won't be found.

The way to fix it is to redirect your difftool config to a script that makes all paths absolute.  This script can then call the real lvcompare.exe.

You just need to tweak the lvcompare part in your .gitconfig to look like this:

[difftool "lvcompare"]
	cmd = ~/bin/lvcompare.sh \"$LOCAL\" \"$REMOTE\"


... and install an executable lvcompare.sh shell script in in your $HOME/bin.  Something like this:

#!/bin/sh

abspath () {
	(
		cd "$(dirname "$1")" &&
		printf "%s/%s" "$(pwd)" "$(basename "$1")"
	)
}

lvcompare="C:\\Program Files (x86)\National Instruments\\Shared\\LabVIEW Compare\\LVCompare.exe"
local=$(abspath "$1")
remote=$(abspath "$2")
exec "$lvcompare" "$local" "$remote"

> 2) C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National 
> Instruments\Shared\L abVIEW Compare\LVCompare.exe" 
> C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl Typedefs\TestStatus.ctl
> 
> Result: Error message with reference to C:\Program Files 
> (x86)\National Instruments\Shared\L abVIEW 
> Compare\supportVIs\_prolvcmp.llb\Typedefs\TestStatus.ctl
> 
> Observation: The second path has to be the full path, not the relative path we get back using "echo".

Yes, that's what it looks like.
--
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: difftool sends malformed path to exernal tool on Windows
  2014-03-05  8:25         ` David Aguilar
  2014-03-05 22:28           ` Paul Lotz
@ 2014-03-07 16:07           ` Paul Lotz
  2014-03-16  7:27             ` David Aguilar
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Lotz @ 2014-03-07 16:07 UTC (permalink / raw)
  To: 'David Aguilar'; +Cc: 'Git Mailing List'

David,

I investigated further and found that \"$LOCAL\" \"$REMOTE\" return the remote and local files (reversed).  (One can easily see this in my 2/28 e-mail.)  Reversing these (\"$REMOTE\" \"$LOCAL\") does indeed reverse the output.  It is easy to work around this issue, but how can this be?

Paul

-----Original Message-----
From: Paul Lotz [mailto:plotz@lsst.org] 
Sent: Wednesday, March 5, 2014 3:28 PM
To: 'David Aguilar'
Cc: 'Git Mailing List'
Subject: RE: difftool sends malformed path to exernal tool on Windows

David,

We did succeed in getting a script to work.  The local Git guru started with your script (he independently sent me something very similar) and added some tricks to make things work.

The contents of the shell script ended up as:
___
#!/bin/bash

# Method to determine absolute path
# The -W option on the pwd command is necessary to return the Windows version of the path.
# Leaving off the -W option will result in a conversion of temp directory to a Linux-specific 'tmp' path.
# Piping the result through tr '/' '\\' translates the forward slashes to backslashes.
# Windows understands forward slashes, but LVCompare.exe does not.
abspath () {
	(
		DIR=$(dirname "$1")
		FN=$(basename "$1")
		cd "$DIR"
		printf "%s/%s" "$(pwd -W)" "$FN" | tr '/' '\\'
	)
}

lvcompare="C:\\Program Files (x86)\National Instruments\\Shared\\LabVIEW Compare\\LVCompare.exe"
local=$(abspath "$1")
remote=$(abspath "$2")
exec "$lvcompare" -nobdpos -nofppos "$local" "$remote"
# For the options, see http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configlvcomp_thirdparty/.
___

This works, but the solution seems to me nontrivial.

I will post this solution in Git with LabVIEW threads tomorrow, but I thought I'd see if you have any suggestions before I do that.

Thanks much!

Paul

-----Original Message-----
From: David Aguilar [mailto:davvid@gmail.com]
Sent: Wednesday, March 5, 2014 1:25 AM
To: Paul Lotz
Cc: 'Git Mailing List'
Subject: Re: difftool sends malformed path to exernal tool on Windows

On Mon, Mar 03, 2014 at 04:24:15PM -0700, Paul Lotz wrote:
> David,
> 
> OK, I did as you suggested, and the results were revealing.
> 
> First, I replaced "echo" with "cat".  Result: The contents of both files appeared in the Git Bash Window.
> 
> Then I tried calling LVCompare from the Git Bash and Windows Command Prompt windows with variations on the paths.
> 
> Here are the most relevant results:
> First from the Windows Command Prompt:
> 1) This command works:
> C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National 
> Instruments\Shared\L abVIEW Compare\LVCompare.exe"
> C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl C:\LSST_TS\SystemSW\M2AADT\Typedefs\TestStatus.ctl
> [General note:
> I saved a copy of the temp file and replaced the hex string with the 
> string 'Before' to make the file stick around.  The paths are 
> otherwise the same.]

This is aligns with: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configlvcomp_thirdparty/

	"lvcompare.exe <absolute path to VI 1> ..."

The key thing is the mention of absolute paths.

What is happening is that lvcompare.exe (or likely it's a Windows thing) changes its current directory to its installation directory under Progra~1.

That means the relative paths passed in by difftool won't be found.

The way to fix it is to redirect your difftool config to a script that makes all paths absolute.  This script can then call the real lvcompare.exe.

You just need to tweak the lvcompare part in your .gitconfig to look like this:

[difftool "lvcompare"]
	cmd = ~/bin/lvcompare.sh \"$LOCAL\" \"$REMOTE\"


... and install an executable lvcompare.sh shell script in in your $HOME/bin.  Something like this:

#!/bin/sh

abspath () {
	(
		cd "$(dirname "$1")" &&
		printf "%s/%s" "$(pwd)" "$(basename "$1")"
	)
}

lvcompare="C:\\Program Files (x86)\National Instruments\\Shared\\LabVIEW Compare\\LVCompare.exe"
local=$(abspath "$1")
remote=$(abspath "$2")
exec "$lvcompare" "$local" "$remote"

> 2) C:\LSST_TS\SystemSW\M2AADT>"C:\Program Files (x86)\National 
> Instruments\Shared\L abVIEW Compare\LVCompare.exe"
> C:\Users\Paul\AppData\Local\Temp\Typedefs_TestStat
> us_Before.ctl Typedefs\TestStatus.ctl
> 
> Result: Error message with reference to C:\Program Files 
> (x86)\National Instruments\Shared\L abVIEW 
> Compare\supportVIs\_prolvcmp.llb\Typedefs\TestStatus.ctl
> 
> Observation: The second path has to be the full path, not the relative path we get back using "echo".

Yes, that's what it looks like.
--
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: difftool sends malformed path to exernal tool on Windows
  2014-03-07 16:07           ` Paul Lotz
@ 2014-03-16  7:27             ` David Aguilar
  0 siblings, 0 replies; 10+ messages in thread
From: David Aguilar @ 2014-03-16  7:27 UTC (permalink / raw)
  To: Paul Lotz; +Cc: Git Mailing List

On Fri, Mar 7, 2014 at 8:07 AM, Paul Lotz <plotz@lsst.org> wrote:
> David,
>
> I investigated further and found that \"$LOCAL\" \"$REMOTE\" return the remote and local files (reversed).  (One can easily see this in my 2/28 e-mail.)  Reversing these (\"$REMOTE\" \"$LOCAL\") does indeed reverse the output.  It is easy to work around this issue, but how can this be?
>
> Paul

It's probably working as intended.

The $LOCAL and $REMOTE names come from "git mergetool", where they
have better defined semantics.

In the context of a diff, where we're really comparing "A" and "B"
they have a little less meaning, but the behavior is well-defined.

When you modify a file locally, the default behavior for "git diff" is
to compare your working tree against the index.

The diff will show the changes that will permute the index's copy into
the the worktree's copy. In a sense, your modifications are the
"remote" thing that is being compared against.

That's why you see a temporary file for $LOCAL ("A") and your
worktree's file for $REMOTE (B).

If compare two other things, e.g. "git difftool HEAD~3 HEAD~" then
$LOCAL is HEAD~3 and $REMOTE is HEAD~, and they'll all be temporary
files.

One analogy is that the $LOCAL thing is the starting point and the
$REMOTE thing is what was modified (by the merge) if you think of it
from the merging perspective.

Specific tools (e.g. lvcompare) may need the arguments to be specified
in a specific order for them to make sense, so it's perfectly
acceptable for specific tools to require that $LOCAL and $REMOTE are
swapped.

BTW.. we went through a lot of back-and-forth getting the difftool
setup correct for lvcompare. In the Git source tree there's a
mergetools/ directory where all of the built-in diff/merge tools are
defined. Do you think you might be able to contribute a scriptlet for
lvcompare so that it is natively supported? That'll save future poor
souls from needing to rediscover the correct recipe for getting
lvcompare working with difftool.  Just a thought.

cheers,
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-03-16  7:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 22:14 difftool sends malformed path to exernal tool on Windows Paul Lotz
2014-02-21 10:38 ` David Aguilar
2014-02-24 16:44   ` Paul Lotz
2014-03-03  0:35     ` David Aguilar
2014-03-03 23:24       ` Paul Lotz
2014-03-05  8:25         ` David Aguilar
2014-03-05 22:28           ` Paul Lotz
2014-03-07 16:07           ` Paul Lotz
2014-03-16  7:27             ` David Aguilar
2014-02-28 15:56   ` Paul Lotz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.