Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Upgrade to latest libgit2 #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2015
Merged

Upgrade to latest libgit2 #1124

merged 2 commits into from
Jul 4, 2015

Conversation

nulltoken
Copy link
Member

No description provided.

@nulltoken
Copy link
Member Author

This has to be locally run against the NuGet package that can be downloaded here

@nulltoken
Copy link
Member Author

The fixup commit fixes some borked tests. @Therzok can you please review the changes?

@nulltoken
Copy link
Member Author

Remaining failing tests are submodule related

Test 'LibGit2Sharp.Tests.SubmoduleFixture.CanStageChangeInSubmoduleViaIndexStageWithOtherPaths(submodulePath: "sm_changed_head", appendPathSeparator: True)' failed:
    Assert.NotNull() Failure
    SubmoduleFixture.cs(169,0): at LibGit2Sharp.Tests.SubmoduleFixture.CanStageChangeInSubmoduleViaIndexStageWithOtherPaths(String submodulePath, Boolean appendPathSeparator)

Test 'LibGit2Sharp.Tests.SubmoduleFixture.CanStageChangeInSubmoduleViaIndexStage(submodulePath: "sm_changed_head", appendPathSeparator: True)' failed:
    Assert.NotNull() Failure
    SubmoduleFixture.cs(146,0): at LibGit2Sharp.Tests.SubmoduleFixture.CanStageChangeInSubmoduleViaIndexStage(String submodulePath, Boolean appendPathSeparator)

@dahlbyk Any chance you could peek at those and determine if our previous expectations were sound or not? Would it be some regression at the libgit2 level or some over-engineered testing at our level?

/cc @carlosmn @whoisj @jamill

@@ -19,5 +19,10 @@ public enum StashApplyStatus
/// The stash index given was not found.
/// </summary>
NotFound,

/// <summary>
/// The stash index given was not found.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh

@nulltoken
Copy link
Member Author

@dahlbyk Any chance you could peek at those and determine if our previous expectations were sound or not? Would it be some regression at the libgit2 level or some over-engineered testing at our level?

It looks like @carlosmn thinks it might be a regression as git.git seems to not choke on trailing path separators.

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.55\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.55\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.60-pre20150627175731\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.60-pre20150627175731\build\LibGit2Sharp.NativeBinaries.props')" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version in folders = 😿

Could look into Paket to make working with Nuget easier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not to well versed in Paket. I'm really not against giving a try, but I'd rather assess it post 1.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dahlbyk Those versions are managed by NuGet as part of the package update process. I'm not sure I see how you'd be able to avoid having those version numbers there since that's how NuGet works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that being able to remove a version number from the path is a benefit that outweighs the cost of switching to entirely different package manager. That's one more thing someone would need to understand just to be able to contribute to the project.

@dahlbyk
Copy link
Member

dahlbyk commented Jun 29, 2015

@dahlbyk Any chance you could peek at those and determine if our previous expectations were sound or not? Would it be some regression at the libgit2 level or some over-engineered testing at our level?

It looks like @carlosmn thinks it might be a regression as git.git seems to not choke on trailing path separators.

Agreed. Easy enough to drop the trailing / in LG2S, but it's probably more correct to fix in LG2.

@carlosmn
Copy link
Member

There's a PR for that! libgit2/libgit2#3269

@nulltoken nulltoken force-pushed the ntk/upgrade branch 2 times, most recently from 91a28d0 to 05458fe Compare June 30, 2015 22:10
@nulltoken
Copy link
Member Author

Hmmm Something weird happened:

From https://ci.appveyor.com/project/libgit2/libgit2sharp/build/1091/job/jaovmnrhy66x3586

LibGit2Sharp.Tests.FilterFixture.DoubleRegistrationFailsButDoubleDeregistrationDoesNot [FAIL]
   Assert.Equal() Failure
   Expected: 0
   Actual:   1
   Stack Trace:
      c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(240,0): at LibGit2Sharp.Tests.FilterFixture.DoubleRegistrationFailsButDoubleDeregistrationDoesNot()

From https://ci.appveyor.com/project/libgit2/libgit2sharp/build/1092/job/b49m75hp4dc73w2y

LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles [FAIL]
   Assert.Equal() Failure
   Expected: 134217728
   Actual:   268435456
   Stack Trace:
      c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(229,0): at LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles()

.LibGit2Sharp.Tests.FilterFixture.InitCallbackMadeWhenUsingTheFilter [FAIL]
   LibGit2Sharp.EntryExistsException : A filter with the name 'the-filter' is already registered
   Stack Trace:
      c:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs(818,0): at LibGit2Sharp.Core.Proxy.git_filter_register(String name, IntPtr filterPtr, Int32 priority)
      c:\projects\libgit2sharp\LibGit2Sharp\FilterRegistration.cs(32,0): at LibGit2Sharp.FilterRegistration..ctor(Filter filter, Int32 priority)
      c:\projects\libgit2sharp\LibGit2Sharp\GlobalSettings.cs(233,0): at LibGit2Sharp.GlobalSettings.RegisterFilter(Filter filter, Int32 priority)
      c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(86,0): at LibGit2Sharp.Tests.FilterFixture.InitCallbackMadeWhenUsingTheFilter()

This is running against latest libgit2 tip once #1113 has been merged

/cc @carlosmn @whoisj @ethomson

@whoisj
Copy link

whoisj commented Jun 30, 2015

This failure...

LibGit2Sharp.EntryExistsException : A filter with the name 'the-filter' is already registered

is expected because the prior test failed and did not unregister its filter.

The CanFilterLargeFiles test fails reliably for me on the ntk/upgrade branch, but I'm not 100% certain why.

@whoisj
Copy link

whoisj commented Jun 30, 2015

Despite messing with the test code to try various things, I keep getting the same error:

Test Name: LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles
Test FullName: LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles
Test Source: C:\Src\LibGit2Sharp\LibGit2Sharp.Tests\FilterFixture.cs : line 179
Test Outcome: Failed
Test Duration: 0:00:03.128

Result StackTrace: at LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles() in C:\Src\LibGit2Sharp\LibGit2Sharp.Tests\FilterFixture.cs:line 220
Result Message:
Assert.Equal() Failure
Expected: 134217728
Actual: 267796480

The numbers are the same every time, I'm not sure what to make of them either as these two numbers do not appear to be any kind of magic numbers.

These also happen to be very similar to the numbers AppVeyor is reporting.

LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles [FAIL]
Assert.Equal() Failure
Expected: 134217728
Actual: 268435456
Stack Trace:
c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(229,0): at LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles()

@Therzok
Copy link
Member

Therzok commented Jun 30, 2015

Actual is expected << 1, just sayin'.

@nulltoken
Copy link
Member Author

Actual is expected << 1, just sayin'.

Oh! Well spotted, @Therzok. I didn't see before. I guess that's a new kind of "off by one" error 😜

@nulltoken
Copy link
Member Author

Just pushed up the following patch

diff --git a/LibGit2Sharp.Tests/FilterFixture.cs b/LibGit2Sharp.Tests/FilterFixture.cs
index 5b89180..9f8d18f 100644
--- a/LibGit2Sharp.Tests/FilterFixture.cs
+++ b/LibGit2Sharp.Tests/FilterFixture.cs
@@ -177,7 +177,7 @@ public void WhenCheckingOutAFileFileSmudgeWritesCorrectFileToWorkingDirectory()
         [Fact]
         public void CanFilterLargeFiles()
         {
-            const int ContentLength = 128 * 1024 * 1024;
+            const int ContentLength = 128 * 1024 * 1024 + 17;
             const char ContentValue = 'x';

             char[] content = (new string(ContentValue, 1024)).ToCharArray();

Here are the new numbers

LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles [FAIL]
   Assert.Equal() Failure
   Expected: 134217745
   Actual:   268435456
   Stack Trace:
      c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(229,0): at LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles()

No longer a x2 issue. Padding? Buffering related?

268435456 = 256 * 1024 * 1024

@nulltoken
Copy link
Member Author

diff --git a/LibGit2Sharp.Tests/FilterFixture.cs b/LibGit2Sharp.Tests/FilterFixture.cs
index 9f8d18f..6092970 100644
--- a/LibGit2Sharp.Tests/FilterFixture.cs
+++ b/LibGit2Sharp.Tests/FilterFixture.cs
@@ -177,7 +177,7 @@ public void WhenCheckingOutAFileFileSmudgeWritesCorrectFileToWorkingDirectory()
         [Fact]
         public void CanFilterLargeFiles()
         {
-            const int ContentLength = 128 * 1024 * 1024 + 17;
+            const int ContentLength = 128 * 1024 * 1024 - 13;
             const char ContentValue = 'x';

             char[] content = (new string(ContentValue, 1024)).ToCharArray();

produces

LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles [FAIL]
   Assert.Equal() Failure
   Expected: 134217715
   Actual:   268433408
   Stack Trace:
      c:\projects\libgit2sharp\LibGit2Sharp.Tests\FilterFixture.cs(229,0): at LibGit2Sharp.Tests.FilterFixture.CanFilterLargeFiles()

Interestingly, 268435456 - 268433408 = 2048.

A buffer related issue somewhere?

@whoisj
Copy link

whoisj commented Jul 1, 2015

Well 134217728 was never (>> 1) of 267796480, so I think that it was by change we saw a fluke (nicely rounded one at that).

I'm going to compare the number of callback invocations we receive in vNext vs ntk/upgrade.

@whoisj
Copy link

whoisj commented Jul 1, 2015

Looks like the git_writestream.close fnp is being called more than once, for both clean and smudge.

@whoisj
Copy link

whoisj commented Jul 1, 2015

OK so more digging I'm seeing callbacks in this order: init, create, write (various count), close, free. The interesting part is that I'd only expect to see these calls twice (once for clean and again

When I'd only expect to see a pair of call sets: once for smudge and again for clean.

Current we see clean set, clean set, smudge set, smudge set. Thoughts?

@nulltoken
Copy link
Member Author

/cc @shiftkey @ammeep

string filename = Path.GetFileName(path);
string cachePath = Path.Combine(root, ".git", filename);

if (File.Exists(cachePath))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethomson Is this implementation specific to this test or should something similar should always happen because of racy-git?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unique to this test filter. When going to the ODB, it writes a temp file with the data and returns a unique ID. Then it tests that when going to the workdir, it can replace the data with what was written in the temp file. (This test is basically a poor man's git-media or git-lfs.)

However if your filter was invoked twice (by git re-examining racily clean files, for example) then we should clean up that temp file before trying to append to it. Otherwise you would end up with it duplicated.

@ethomson
Copy link
Member

ethomson commented Jul 4, 2015

@nulltoken Can we update this to the 0.23rc2? What's left to merge this?

@nulltoken
Copy link
Member Author

Can we update this to the 0.23rc2?

@ethomson On it

@nulltoken nulltoken force-pushed the ntk/upgrade branch 2 times, most recently from c1969a5 to c97b142 Compare July 4, 2015 16:56
nulltoken added a commit that referenced this pull request Jul 4, 2015
@nulltoken nulltoken merged commit 37bdb63 into vNext Jul 4, 2015
@nulltoken nulltoken deleted the ntk/upgrade branch July 4, 2015 17:21
@ethomson
Copy link
Member

ethomson commented Jul 4, 2015

❤️

@nulltoken nulltoken added this to the v0.22 milestone Jul 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants