sajalverma17 / GitBranchDiffer

A Visual Studio Extension that displays source files Added/Modified/Renamed between a base branch you choose to diff against, and the current working branch in your Git repo. The diffed files are shown in the Solution Explorer using a Solution Explorer Filter
MIT License
6 stars 1 forks source link

few problems #32

Closed crusader-mike closed 2 years ago

crusader-mike commented 2 years ago

Version Information :

Describe the bug

  1. Doesn't work with files in "Solution items" -- they all get displayed, Open Diff With Base fails with Object reference not set to an instance of an object.
  2. Files that passed the filter also show up in "External Dependencies" of related (C++) projects -- this unnecessarily clutters Solution Explorer view
  3. Open Diff With Base ignores 3rd-party diff tool configured in VS (Araxis Merge in my case)

Expected behavior

  1. files in "Solution items" have to be filtered too
  2. "External dependencies" (and it's parent project) should disappear from the view (unless project has file that passed the filter)
  3. External diff tool has to be used (if configured)
crusader-mike commented 2 years ago

About #1 -- for some reason it affects only .props files

sajalverma17 commented 2 years ago

@crusader-mike First of all, thanks a lot for reporting the bugs! Sorry about a delay in my response. I was on a month long vacation. I looked into these bugs will fix them.

Some investigation tells me that:

However, I found that the filter works fine on files present under Solution Items. Running it on the test repository (found here), shows that only solution items that were edited in feature/test-feature branch of that repo showed up in filter when diffed against master. The README.md found under Solution Item didn't pass the filter.

Maybe you haven't pulled latest for the pair of branches you are diffing before running the diff? I'll release the fix for Open Diff With Base on Solution Items soon and come back to this again if you run into more issues.

I am a bit eager to release the VS2022 support I added, so maybe I'll do a release with bug no.1 and bug no.2 you reported here, and then add support for 3rd party tools after that.

crusader-mike commented 2 years ago
  • 1 - The Open Diff With Base failing with a Null Ref Exception for "Solution Items" was something I found out too and left as a comment to fix later. That is fixed now.

However, I found that the filter works fine on files present under Solution Items. Running it on the test repository (found here), shows that only solution items that were edited in feature/test-feature branch of that repo showed up in filter when diffed against master. The README.md found under Solution Item didn't pass the filter.

Try renaming one of these files into AAA.props -- for some reason all .props files (that normally sit in repo's root directory) don't work.

  • 2 - Good catch, I don't know much about VC++ projects in Visual Studio, but looks like every C++ projects has this folder automatically generated to display .h.hpp files it references from another C++ project. I guess a possible fix is to just ignore a file that was Added/Edited AND if it is under the "External Dependencies " folder.

Sounds like a plan.

  • 3 - Looked into this too. I think this can be done by picking up the 3rd part diff tool configured in .gitconfig file of the repo and opening that tool when you click Open Diff With Base. I guess when you configure in VS's via Tools -> Options -> Source Control -> Git Repository Settings, it would just edits the .gitconfig anyway?

No. Git is not the only SCC tool VS has, hence it stores this option elsewhere. I imagine there should be a way VS extension could kick off comparison tool (as it is configured in VS).

I am a bit eager to release the VS2022 support I added, so maybe I'll do a release with bug no.1 and bug no.2 you reported here, and then add support for 3rd party tools after that.

Fine by me :)

sajalverma17 commented 2 years ago

@crusader-mike So I tried adding an AAA.props file in the root of the repo, and added it as a Solution Items in both the Base branch (master) and a Working branch (feature/test-feature), both identical.

Unfortunately, I still couldn't reproduce the issue of the filter not working on .props files. Switching to the working branch, clicking on the Branch Diff Filter filtered out AAA.props file as expected. If you want to, you can create a branch in test repository and set it up so that diffing with master doesn't work for .props files, I can reproduce it on my machine. I'd really like to fix it but don't have any clues as to what went wrong for you.

No. Git is not the only SCC tool VS has, hence it stores this option elsewhere. I imagine there should be a way VS extension could kick off comparison tool (as it is configured in VS).

Regarding this, I googled it, but only found ways of configuring external diff tools specific to different SSC tools in VS, eg. TFS/Git. In this case, that SSC tool would be Git. Is there such a thing as a default diff tool that can be configured in VS so it uses that tool to run comparisons of a file regardless of the SSC under which the file is versioned? If yes, where do we configure that in VS? Could you find how/where Araxis Merge is configured in your VS? Created a feature issue for this #35 where you can write more.

crusader-mike commented 2 years ago

@sajalverma17 I finally found some time to look into this :)

Issue 1 is no longer a problem, both aspects of it: after extension auto-updated itself -- I can't reproduce anything.

Issue 3 is interesting... Basically when VS deal with Git repo -- it looks at Git related settings:

image

and in those settings you could say "use whatever git has been configured with" or "Use Visual Studio". If former -- it'll (probably) parse .gitconfig and kick off related process. If latter -- start in-VS tool.

For some reason I thought I had Araxis Merge configured in VS options (as it is when you use TFSVC), completely forgot that for Git it happens in global .gitconfig.

Anyways, I was hoping there is a way for VS extension to kick off the same tool as VS does when you click Compare With Unmodified... in Changes tab of Team Explorer...

crusader-mike commented 2 years ago

Could it be one of the SccXXX functions?

sajalverma17 commented 2 years ago

@crusader-mike I couldn't find much in Scc VS API, the SccDiff is for comapring the file with an unmodified version of itself.

I think I will follow what VS does. As the plugin is for Git repositories only, we parse .gitconfig and open an external process. If user has selected "Use Visual Studio", we open a VS comparison window as it opens now (ignore what is confired in TFSVC entirely).

Also, I am a bit skeptical of adding this feature altogether. This is because of the Intellisenseā„¢ that comes with VS comparison. It helps a lot in code reviews to see where the newly added method/property/class is referenced in the checked-out branch, and was one of the goals of this plugin, as opposed to text-based code reviews in external tools.

I may add a checkbox to Git Branch Differ Options , and use external diff.tool set in git config only if the box is checked.