git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: difftool sends malformed path to exernal tool on Windows

From
PLPaul Lotz <plotz@lsst.org>
Date
Mar 7, 2014, 16:07 UTC
Message-ID
<019d01cf3a1f$4ebfe5f0$ec3fb1d0$@lsst.org>
In-Reply-To
<20140305082517.GA86532@gmail.com>
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:
Show 19 quoted lines
> 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"

Show 10 quoted lines
> 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

Previous: Paul LotzNext: David Aguilar
Message 8 of 10 in “difftool sends malformed path to exernal tool on Windows”
  1. Paul LotzFeb 17, 2014
  2. David AguilarFeb 21, 2014
  3. Paul LotzFeb 24, 2014
  4. David AguilarMar 3, 2014
  5. Paul LotzMar 3, 2014
  6. David AguilarMar 5, 2014
  7. Paul LotzMar 5, 2014
  8. Paul LotzMar 7, 2014
  9. David AguilarMar 16, 2014
  10. Paul LotzFeb 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.