Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

SourceTree- VBA Macros via xltrail

jkeeney June 11, 2018

I have been developing some VBA Macros in Excel and I would like to use revision control to help manage the development.

I have discovered https://www.xltrail.com/client which is an open source Git command line extension: git-diff and git-merge.

It seems to work great from the git command line.  However, I am used to using SourceTree.  Anyone know how I can merge these two together?

 

Under git I tried system git instead of embedded.  I also tried playing around with the external diff/merge options.  I couldn't seem to get it right.  

 

xltrail added the following to my .git/config file if this helps.

 

[diff "xltrail"]
   command = git-xltrail-diff.exe
[merge "xltrail"]
   name = xltrail merge driver for Excel workbooks
   driver = git-xltrail-merge.exe %P %O %A %B

 

I am a beginner with Git and SourceTree.  Any help would be greatly appreciated.

5 answers

1 vote
fzumstein December 14, 2018

Hi @Mike Corsaro I am one of the maintainers of git-xltrail. I see that it now works with SourceTree 3.0.12. However, I can only see it working in the case of uncommitted changes, not for already committed changes. Is there a simple reason for why that is? We're happy to do changes on our side as per your suggestion but I was wondering if the current behaviour was expected. Thanks for a quick feedback!

fzumstein January 21, 2019

I wrote a short blog post about how to use SourceTree with git-xltrail: https://dev.to/fzumstein/how-to-diff-excel-vba-code-in-sourcetree-git-client-36k

0 votes
fzumstein September 18, 2019

Just to minimize confusion: We have renamed git-xltrail into Git XL and hence all commands are now "git xl" instead of "git xltrail". Everything else stays the same, but during upgrading it might be best to completely uninstall git-xltrail before you upgrade to git-xl.

0 votes
Tony Pinter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2019

@Mike Corsaro @fzumstein What follows isn't technically an answer, but I figured it would make sense to keep a related beginner xltrail/sourcetree question in the same (and only similar) thread. 

Along similar lines to OP I'm a relative beginner with Git, xltrail, and SourceTree, and I've been playing around with using these tools to manage some xlsm files.

Everything seemed to be working swimmingly, but I ran into some trouble when I edited a VBA module in one of my xlsm files and then observed it in Sourcetree.

2.pngWhen I try to stage or discard lines/hunk, I get the following error:

3.png

The content of that file is:

diff --git a/diff_results.xlsm b/diff_results.xlsm

--- a/diff_results.xlsm   

+++ b/diff_results.xlsm

@@ -11,8 +11,8 @@

' Return code?

Call RunPowerShell(cmd, "CompareResults")

 

[31m-' dummy comment added

[32m+' dummy comment revised after being added

End Sub

 

 Sub CallCompareResults()

I verified that I could discard hunk with a change to a simple text file, so I think my basic sourcetree and repo setup is right.  Perhaps xltrail doesn't support patching like this?  Or might something else be the problem?

0 votes
Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2018

Just to provide an update on this one -- it's going to take a bit longer than expected due to xltrail not producing a standard git diff:

  • It ignores most diff command switches such as color formatting and mnemonicprefix
  • It outputs as if there are multiple files (which is OK), but doesn't add an additional diff header

Thanks for your patience!

jkeeney June 28, 2018

Thanks for the update!

 

Not trying to hold you to anything.  However, do you have an idea if this might be on the order of weeks, months, etc.?

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2018

Probably in the 2.7 release, which will be coming in the next few weeks.

Daniel Shunfenthal June 29, 2018

A couple weeks is pretty good, thanks!

Should those issues be brought up to them? Or do you think you can handle it on your end?

As an aside, I would've thought color formatting is handled by SourceTree?

Daniel Shunfenthal September 10, 2018

@Mike CorsaroIs there any update to this out of curiosity? Is it still slated for the next release, and if so do you know when that is coming out?

Kade333 March 27, 2019

@Mike Corsaro

I have installed xltrial and it works as intended in the command window as intended.

image.png

 

Unfortunately, it is not showing up in the GUI window as shown here.

image.png

 

I am running version SourceTree version 3.1.2.

Is there something else I am supposed to to in order to get this to work, or are you still working on the patch?

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2019

Seems to work fine for me?

diff.PNG

Are you sure you have everything configured?

Open the Process Log (Tools > Process Viewer...), click on the file to generate the diff, and then check the process output. It should look something like this:

[1mdiff --xltrail a/Book1.xlsb b/Book1.xlsb
[1m--- a/Book1.xlsb/VBA/Module/Module1
[1m+++ b/Book1.xlsb/VBA/Module/Module1
[36m@@ -2,3 +2,7 @@
'test1
Sub test()
Debug.Print "hello1"
[32m+End Sub
[32m+
[32m+
[32m+gsdgdsg
fzumstein March 27, 2019

Hey @Mike Corsaro , I think what might happen is that @Kade333 is looking at two historical commits, while you're looking at pending commits (where it works). Is there anything we'll need to change (I am one of the maintainers) to make it work for historic commits, too?

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2019

@fzumsteinnothing you need to do on your side -- looks like 'diff-tree' doesn't have the default diff settings of '--ext-diff' like 'log' and 'diff' does for some reason. I'll add it to our backlog and hopefully it will be included in the next release.

fzumstein March 27, 2019

awesome, thanks!

sai velagapudi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 30, 2019

Hey @fzumstein , your blog is great and very helpful. I recently started developing VBA and started to use Sourcetree along with my other Java projects. I can't wait to be able to compare historical diff's.

@Mike Corsaro , Any ETA on the timeline for this?

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2019

It's been fixed in 3.1.3 which is at 25% in our progressive rollout. You can also manually download it here.

Like Ana Retamal likes this
sai velagapudi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 1, 2019

Cool.Thanks

Andrew Dorfman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2019

@Mike Corsaro , thanks, I was struggling to make SourceTree (v3.2.6) work with that but couldn't and after I posted a question here it started to work)

Actually I believe there is still a problem in some cases: there is one command (from the logs) that is not calling Git XL and the other command is calling it and producing a proper diff output.

The command #1 that works - as it is in my SourceTree log file:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks diff-tree --oneline --unified=3 --root -w -M -C --ext-diff 6b4...3b7 -- \"Test_GitXL/Variation.xlsm\"

This command #2 doesn't work with Git XL: 
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks diff --unified=3 -M --no-color -- \"Test_GitXL/Orica Contract Variation.xlsm\"

"Output" of second command is : "diff --git a/Test_GitXL/Variation.xlsm b/Test_GitXL/Variation.xlsm\nindex 0a51..1fec 100644\nBinary files a/Test_GitXL/Variation.xlsm and b/Test_GitXL/Variation.xlsm differ\n"

Output from command #1 is meaningfull diff results...

Possibly I'm missing something in my Git knowledge, can't see why #1 works while #2 doesn't.... difference is that #1 has diff-tree and ext-diff... but what does that mean?

Andrew D

0 votes
Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2018

Hello! Sourcetree doesn't currently support doing this as we explicitly disallow external diff drivers for specific file types. However, I don't see why we couldn't support this as it's a pretty small change for us to make.

jkeeney June 13, 2018

For what it is worth, that would be a huge help to me.

 

SourceTree is a critical part of my development for all of the other languages I code in.  Being able to use SourceTree for my VBA development would be a huge win.

I still use it, but not being able to use diff and merge limits its usefulness.

Thanks for considering this!

Daniel Shunfenthal June 27, 2018

Hey, just wanted to throw my support in for this as well! It would be so nice to be able to use xltrail + Sourcetree's diff viewer.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events