Skip to content

Update configuration bindings#234

Closed
yorah wants to merge 9 commits into
libgit2:vNextfrom
yorah:topic/update-configuration-bindings
Closed

Update configuration bindings#234
yorah wants to merge 9 commits into
libgit2:vNextfrom
yorah:topic/update-configuration-bindings

Conversation

@yorah

@yorah yorah commented Oct 24, 2012

Copy link
Copy Markdown
Contributor

Update bindings to the last version of libgit2, following the work that has been done on the config part (libgit2/libgit2#923).

This PR does not contain the updated DLLs. I'm developping locally until vNext is updated.

Currently a WIP.

@yorah

yorah commented Oct 24, 2012

Copy link
Copy Markdown
Contributor Author

@dahlbyk I cherry-picked some of your commits from #232 related to 67fa534 ("Simplify Configuration.Get() usage"). I squashed them together here.

Taking into account this comment and #162, and considering that we now always return a ConfigurationEntry (which can be null), maybe c975958 ("Support getting nullable configuration values") isn't necessary anymore?

@dahlbyk

dahlbyk commented Oct 24, 2012

Copy link
Copy Markdown
Member

Taking into account this comment and #162, and considering that we now always return a ConfigurationEntry (which can be null), maybe @c975958 ("Support getting nullable configuration values") isn't necessary anymore?

It's not as useful now, but it should still be trivial to support the nullable values should a client need them.

Regardless of nullable support, for ease of consuming a null entry I'd suggest adding an extension method along the lines of...

T ValueOrDefault<T>(this ConfigurationEntry<T> @this, T defaultValue = default(T))

@nulltoken

Copy link
Copy Markdown
Member

@yorah Could you please rebase this on top of vNext?

Note: You may have messed up the rewrite of @dahlbyk's commit message. (094d00f is piling up on 3c2d0fc)

@nulltoken

Copy link
Copy Markdown
Member

Regardless of nullable support, for ease of consuming a null entry I'd suggest adding an extension method along the lines of...

T ValueOrDefault<T>(this ConfigurationEntry<T> @this, T defaultValue = default(T))

ConfigurationExtensions to the rescue!

@nulltoken

Copy link
Copy Markdown
Member

@yorah Could you please rebase this on top of vNext?

@nulltoken

Copy link
Copy Markdown
Member

@yorah Could you please rebase this on top of vNext?

@yorah I'm on it. Will push a proposal for you to review later today.

@nulltoken

Copy link
Copy Markdown
Member

@yorah rebase has been done.

Could you please peek at https://github.com/nulltoken/libgit2sharp/commits/yorah-config?

@yorah

yorah commented Nov 9, 2012

Copy link
Copy Markdown
Contributor Author

@nulltoken Nice!

I introduced usage of git_config_open_level in the Configuration class, when we get/set a key of a specific store.
I also added XDG handling in LibGit2Sharp (basically, the escalation logic when reading is local -> global -> XDG -> system, and when writing the escalation logic has to be implemented by the client).

@nulltoken

Copy link
Copy Markdown
Member

@yorah That's an awesome job!

Just a slight issue, The TeamCity CI server complains. An extract of the Mono build log is listed below.

[LibGit2Sharp.Tests.dll] LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] mono: /home/monoagent/.build-agent/work/314f63821baef1ff/libgit2/src/config.c:130: find_internal_file_by_level: Assertion `cfg->files.length' failed.
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] Stacktrace:
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] 
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at <unknown> <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_config_open_level (LibGit2Sharp.Core.Handles.ConfigurationSafeHandle&,LibGit2Sharp.Core.Handles.ConfigurationSafeHandle,uint) <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at LibGit2Sharp.Core.Proxy.git_config_open_level (LibGit2Sharp.Core.Handles.ConfigurationSafeHandle,LibGit2Sharp.ConfigurationLevel) <0x0005a>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at LibGit2Sharp.Configuration.RetrieveConfigurationHandle (LibGit2Sharp.ConfigurationLevel,bool) <0x0003b>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at LibGit2Sharp.Configuration.Set<int> (string,int,LibGit2Sharp.ConfigurationLevel) <0x00054>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at LibGit2Sharp.Tests.ConfigurationFixture/<SettingLocalConfigurationOutsideAReposThrows>c__AnonStoreyE.<>m__15 () <0x00034>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Record.Exception (Xunit.Assert/ThrowsDelegate) <0x00023>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Assert.Throws (System.Type,Xunit.Assert/ThrowsDelegate) <0x00022>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Assert.Throws<T> (Xunit.Assert/ThrowsDelegate) <0x00032>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows () <0x000d3>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at <unknown> <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x001bd>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002a>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.Reflector/ReflectionMethodInfo.Invoke (object,object[]) <0x0012f>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.FactCommand.Execute (object) <0x00038>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.FixtureCommand.Execute (object) <0x0020e>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.BeforeAfterCommand.Execute (object) <0x0017c>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.LifetimeCommand.Execute (object) <0x000f5>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.ExceptionAndOutputCaptureCommand.Execute (object) <0x00500>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.TimedCommand.Execute (object) <0x00075>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.TestClassCommandRunner.Execute (Xunit.Sdk.ITestClassCommand,System.Collections.Generic.List`1<Xunit.Sdk.IMethodInfo>,System.Predicate`1<Xunit.Sdk.ITestCommand>,System.Predicate`1<Xunit.Sdk.ITestResult>) <0x0046a>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.Executor/RunAssembly/<>c__DisplayClass9.<.ctor>b__4 () <0x00341>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at Xunit.Sdk.Executor.ThreadRunner (object) <0x0006c>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at System.Threading.Thread.StartInternal () <0x000a3>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]   at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] 
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] Native stacktrace:
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows] 
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /home/monoagent/.mope/versions/3.0.0/bin/mono() [0x4975d6]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /lib/libpthread.so.0(+0xeff0) [0x7fcc4611bff0]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /lib/libc.so.6(gsignal+0x35) [0x7fcc45ddd1b5]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /lib/libc.so.6(abort+0x180) [0x7fcc45ddffc0]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /lib/libc.so.6(__assert_fail+0xf1) [0x7fcc45dd6301]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /home/monoagent/.build-agent/work/314f63821baef1ff/cmake-build/libgit2-bin/lib/libgit2.so(+0x5adbe) [0x7fcc41909dbe]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    /home/monoagent/.build-agent/work/314f63821baef1ff/cmake-build/libgit2-bin/lib/libgit2.so(git_config_open_level+0x2a) [0x7fcc4190a042]
[20:29:38][LibGit2Sharp.Tests.ConfigurationFixture.SettingLocalConfigurationOutsideAReposThrows]    [0x40e80862]

@nulltoken

Copy link
Copy Markdown
Member

@yorah I've found the root cause. See libgit2/libgit2#1059

@yorah

yorah commented Nov 9, 2012

Copy link
Copy Markdown
Contributor Author

@nulltoken Nice! 🙇

@yorah

yorah commented Nov 23, 2012

Copy link
Copy Markdown
Contributor Author

Rebased on half-ogre.

@haacked

haacked commented Dec 4, 2012

Copy link
Copy Markdown
Contributor

Is there anything this is waiting on? I'm looking forward to being able to use this. 😄

@nulltoken

Copy link
Copy Markdown
Member

Is there anything this is waiting on?

It'll be merged as soon as #260 is in.

@nulltoken

Copy link
Copy Markdown
Member

@yorah Sorry for the delay. It's now merged in vNext 💖

@haacked Here you are, Sir!

@nulltoken nulltoken closed this Dec 5, 2012
@haacked

haacked commented Dec 5, 2012

Copy link
Copy Markdown
Contributor

Woohoo!

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.

4 participants