laurentkempe / GitDiffMargin

Git Diff Margin displays live Git changes of the currently edited file on Visual Studio margin and scroll bar. Supports Visual Studio 2012 through Visual Studio 2022
https://marketplace.visualstudio.com/items?itemName=LaurentKempe.GitDiffMargin
MIT License
290 stars 39 forks source link

Extension doesn't work in case of sparse checkout and partial clone #356

Open EugeniyMaksimov opened 3 years ago

EugeniyMaksimov commented 3 years ago

Hello!

Versions

What happened

Change markers (yellow lines, red triangles) are not shown if the project is in the repository, where sparse checkout and partial clone git features are used.

Steps to Reproduce

I have two repository, in regular one everything is fine, but in the other, where the sparse checkout and partial clone features are used, there is no any markers.

laurentkempe commented 3 years ago

Thanks @EugeniyMaksimov for reporting it! I will have a look asap. I guess the version of Git Diff Margin has a typo and you mean 3.10.2?

EugeniyMaksimov commented 3 years ago

Thank you very much! I've corrected the typo in the Git Diff Margin version. I think, the Sparse Checkout is a great feature of Git, I believe, a lot of people will use it, especially when Git Hub supports it.

laurentkempe commented 3 years ago

I just have seen on the documentation that

THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN THE FUTURE.

Nevertheless, could you give me an example of the command you are using on an existing repository which I could use to test?

EugeniyMaksimov commented 3 years ago

mkdir work cd work git clone -b --filter=blob:none --no-checkout . git config core.sparsecheckout true git sparse-checkout init --cone git sparse-checkout set git read-tree -mu HEAD git remote add upstream git fetch --all

I also tried full clone: git clone -b --no-checkout . the result is the same

laurentkempe commented 3 years ago

I tried the command you are listing but cannot make it work, imagine I would like to do it with this repo - https://github.com/laurentkempe/DynamicRun.git

If I try what you also tried

git clone -b --no-checkout https://github.com/laurentkempe/DynamicRun.git

I get the following

Cloning into 'DynamicRun'...
fatal: Remote branch --no-checkout not found in upstream origin
EugeniyMaksimov commented 3 years ago

Hi Laurent, This is a full listening of commands I used to clone the DynamicRun repository. I used the Power Shell console.

PS C:\New folder> git clone -b master --no-checkout https://github.com/laurentkempe/DynamicRun.git . Cloning into '.'... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (13/13), done. remote: Total 92 (delta 4), reused 2 (delta 1), pack-reused 78 Unpacking objects: 100% (92/92), 35.12 KiB | 115.00 KiB/s, done. PS C:\New folder> git config core.sparsecheckout true PS C:\New folder> git sparse-checkout init --cone PS C:\New folder> git sparse-checkout set DynamicRun PS C:\New folder> git read-tree -mu HEAD PS C:\New folder> git fetch --all Fetching origin PS C:\New folder>

laurentkempe commented 3 years ago

Thanks @EugeniyMaksimov I could do a sparse checkout of DynamicRun now and can reproduce the issue that no changes are shown with Git Diff Margin. I also learned about something new. I need to go deeper into why it is like that, but my first guess is that the https://github.com/libgit2/libgit2sharp/, which Git Diff Margin is using, is not supporting sparse checkout which seems quite new.

laurentkempe commented 3 years ago

I can confirm that the issue comes from libgit2sharp

Git Diff Margin get an exception unsupported repository version 1. Only versions up to 0 are supported. while creating a Repository on this line.

So, I guess there is not much I can do about it!

EugeniyMaksimov commented 3 years ago

Hello Laurent, Thank you for the investigation! I think the best idea in this case is to write an issue in the libgit2sharp project. Here it is: https://github.com/libgit2/libgit2sharp/issues/1845

laurentkempe commented 3 years ago

Hello Eugeniy You are welcome, thanks for reporting it! The issue is that libgit2sharp is missing a maintainer so I do not expect too much from it.

miniyou commented 3 years ago

Hi!

Git Diff Margin works for me in the main repo folder. However, I get nothing in the margin for projects that are in another work tree, i.e. added with git worktree add …. It seems plausible that this is for the same reason, but I'm not sure how to verify.

Git Diff Margin version: 3.10.2.268 VS Pro 2019 version: 16.8.2 Git version: 2.30.0.windows.2

Ps. thanks for a great extension!

laurentkempe commented 3 years ago

Thanks @miniyou for your nice message! You can also add a star to the project on Github to show your recognition and on Visual Studio Git Diff Margin marketplace Worktree are mentioned in #88 as I also use those from time to time and faced the same issue.