Example Code

LVCompare Adapter for GIT Extensions

Code and Documents

Attachment

Download All

Description

There are some restrictions to LVCompare that make calling it from GIT Extensions a daunting task:

  1. GIT's $LOCAL variable represents the file's path relative to the repo's root directory.  Since LVCompare expects absolute paths to the VIs to be compared, this imposes a problem.  The obvious solution is to print the working directory (with $PWD) and concatenate it with the VI's relative path.  That solves problem one, but takes us to problem two.
  2. GIT Extensions uses mingw for git bash, meaning file paths are passed with forward slash '/' instead of windows backslash '\'.  On Windows, LabVIEW will not interpret the "forward slashed" file paths as valid.  Therefore, attempts to pass the concatenated path (or any path at all) to LVCompare are futile.  The solution to problem number two is detailed below.

To resolve issue two, I built a simple adapter executable that reinterprets the file paths, then forwards along the arguments to LVCompare.  The result is easy right-click .VI diffing in GIT Extensions.

 

Dependencies

LabVIEW 2017 SP1 f1 Runtime - Included in the installer.

 

Setup

The included installer will place the lvcomparegit.exe in Program Files\National Instruments\LVCompare Git Adapter\.

As an alternative, place the included executable anywhere you would like.

 

2018-02-26_1514.png

 

2018-02-26_1509.png

 

2018-02-26_1512.png

 

I hope others find this tool useful when the same need arises.

 

Installer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
the_mitten
NI Employee (retired)
on

I should have known you would have already solved this problem for me... thanks Sean!

Regards,

Michael Whitten
Senior RF Applications Engineer
hanrock
Member
Member
on

Great. It solved my pain on VI diff.

StefanLemmens
Member Member
Member
on

Thanks for this great tool. Would it be possible to add 2 improvements?

  • Check if "C:\Program Files\National Instruments\Shared\LabVIEW Compare\LVCompare.exe" exists before using it as a default lvcomparepath, otherwise use "C:\Program Files (x86)\National Instruments\Shared\LabVIEW Compare\LVCompare.exe"
  • If both files (from $LOCAL and $REMOTE) have the same filename then copy $REMOTE to the temp folder and rename it.

The last one is a current problem that we got while using Git Fork. Since the latest version of Fork doesn't rename the file anymore. LVCompare can't compare 2 files with the same filename.

It would solve this issue:

https://forums.ni.com/t5/WUELUG-W%C3%BCrzburg-LabVIEW-User/Set-up-Fork-for-GitLab/td-p/4192959

 

The attached screenshot shows both modifications.

 

Modified LVCompare Adapter for GIT.PNG

 

Best Regards,

Stefan Lemmens

StefanLemmens
Member Member
Member
on

An updated version of the tool can be found here.

Best Regards,

Stefan Lemmens

Contributors