xltrail / git-xl

Git extension: Makes git-diff work for VBA in Excel workbooks (xls* file types)
https://www.xltrail.com/git-xl
MIT License
561 stars 72 forks source link

Merging wbs with userform changes fastforwards instead of merges #35

Closed gnsoria closed 5 years ago

gnsoria commented 5 years ago

When trying to merge two workbooks, one with just a code change and one with a conflicting code change and a change to a userform object, xltrail fast-forwards to the one with the userform change and doesn't raise a merge conflict. Both commits show up in the log. When diffing between them, the conflicting code change appears.

This is the first bug report I'm made so I'm not sure what info you need, but if it helps, here's what I'm seeing on the command line:

C:\Users\gnsoria\macros>git merge Bug2
Updating 71bdbc5..71b7639
Fast-forward
 CTMAddIn.xlam | Bin 576174 -> 577881 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

C:\Users\gnsoria\macros>git log --oneline -2
71b7639 (HEAD -> Bug1, Bug2) Testing userform bug 2. Some userform changes.
71bdbc5 Testing userform bug. No userform changes made.

C:\Users\gnsoria\macros>git diff 71bdbc5..71b7639
diff --xltrail a/CTMAddIn.xlam b/CTMAddIn.xlam
--- a/CTMAddIn.xlam/VBA/Module/zTests_GS
+++ b/CTMAddIn.xlam/VBA/Module/zTests_GS
@@ -4,7 +4,7 @@
Sub testingxlTrailBug()
     On Error GoTo errHandler

-    Debug.Print "Bug 1 testing. No userform changes."
+    Debug.Print "Bug 2 testing. Some userform changes."

 Exit Sub
 errHandler:
fzumstein commented 5 years ago

Thanks for reporting, we'll be trying to replicate this. To clarify, by changing a user form object, you are referring to moving a text box (let's say) without changing the underlying VBA code, correct?

gnsoria commented 5 years ago

@fzumstein correct. I didn't check to see if this occurs when code is changed in the userform, but my gut tells me probably not?

fzumstein commented 5 years ago

@gnsoria could be please check if you still get this error with the latest version (0.4.1)? My guess is that this was fixed by https://github.com/xlwings/git-xl/issues/40

gnsoria commented 5 years ago

@fzumstein Sorry for the delay in response. I'm trying to check this but got a new computer and had to switch from xltrail (no longer installed) to XL. I'm unable to use git with my repo. Can you tell me if there is an existing solution to this?

error: cannot spawn git-xltrail-diff.exe: No such file or directory
fatal: external diff died, stopping at CTMAddIn.xlam

If not, I can make a separate issue.

Until I can get that sorted out, I can't check to make sure this is fixed.

Thanks!

fzumstein commented 5 years ago

Hi @gnsoria, sorry the migration docs are currently not existing - I'll fix that. Did you use the local installation that writes to your .gitattributes file? Simply go in there and replace all occurrences of xltrail with xl.

gnsoria commented 5 years ago

@fzumstein ah, that solved it the transition issue.

Ok, I did my best to reproduce the original bug. It appears to still be broken, but in a different way. I realize now that I didn't leave great instructions here for how to reproduce (sorry!) so here's what I did this time:

It looks like it properly marks the merge conflict in the code now (success). Unfortunately, it seemed to revert the userform change I made, and I couldn't see any way to tell it which userform version to accept. Also, the userform in the VB Editor is abnormally small, even though the zoom is normal. Loading the userform in a spreadsheet looks normal; it's just when I try to edit it. This weird zoom sticks around even if I close Excel and reopen.

fzumstein commented 5 years ago

Great to hear the migration worked.

Since we only merge VBA code, sheets and everything else (including user forms) will behave the same as without Git XL. That is, it'll show just one version, yes. Have a look at my recent blog post to see if that helps? https://www.xltrail.com/blog/merge-excel-workbooks-with-git

gnsoria commented 5 years ago

Hmm, ok. I suppose that does make sense. So it'll merge the VBA code (even code in the userform?) but stick with master's version of the userform (or whichever branch you're merging into)?

fzumstein commented 5 years ago

Yes, the VBA part of user forms, too. And yes, Git's behaviour is to stick with the current version of your branch (but the file will be marked as merge conflict, so you'll need to resolve that). I am closing this issue as I consider this resolved. Feel free to re-open if you have more issues.

gnsoria commented 5 years ago

I really appreciate the help @fzumstein!