| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I can see that it would probably be difficult to unit test this (unless we add some functionality to get the user agent in libgit2 - which we probably should do). I can add that, but in the meantime, I think that yes, sniffing in wireshark or fiddler would be good. Or at least stepping through in a debugger to make sure that things land in the native side correctly. I added a few notes regarding that, but I'm not sure that they're exhaustive, so I think that you should check to see how this is landing in the native side. |
Sorry, something went wrong.
| /// </param> | ||
| public static void SetUserAgent(ConfigurationLevel level, string userAgent) | ||
| { | ||
| Proxy.git_libgit2_opts_set_user_agent(level, userAgent); |
There was a problem hiding this comment.
There's no ConfigurationLevel for this call - it doesn't have anything to do with configuration. It only takes a user agent string and is applied to the entirety of the library.
Sorry, something went wrong.
|
This will be great to have, thanks for tackling this! |
Sorry, something went wrong.
|
Didn't know you could just use vargs without __listargs. The mono tracer is saying that it is entering and leaving the function: [0x7f1d7a7727c0: 0.00573 0] ENTER: LibGit2Sharp.Core.Proxy:git_libgit2_opts_set_user_agent (string)([STRING:0x7f1d7a6b8130:txdv], ) [0x7f1d7a7727c0: 0.00611 1] ENTER: LibGit2Sharp.Core.NativeMethods:.cctor ()() [0x7f1d7a7727c0: 0.00612 2] ENTER: LibGit2Sharp.Core.Platform:get_OperatingSystem ()() [0x7f1d7a7727c0: 0.00613 2] LEAVE: LibGit2Sharp.Core.Platform:get_OperatingSystem ()result=1 [0x7f1d7a7727c0: 0.00630 2] ENTER: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()() [0x7f1d7a7727c0: 0.00755 2] LEAVE: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()result=1 [0x7f1d7a7727c0: 0.00792 2] ENTER: LibGit2Sharp.Core.Ensure:.cctor ()() [0x7f1d7a7727c0: 0.00968 2] LEAVE: LibGit2Sharp.Core.Ensure:.cctor () [0x7f1d7a7727c0: 0.00969 2] ENTER: LibGit2Sharp.Core.Ensure:Int32Result (int)(1, ) [0x7f1d7a7727c0: 0.00970 2] LEAVE: LibGit2Sharp.Core.Ensure:Int32Result (int) [0x7f1d7a7727c0: 0.00975 2] ENTER: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_openssl_set_locking ()() [0x7f1d7a7727c0: 0.00977 2] LEAVE: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_openssl_set_locking ()result=0 [0x7f1d7a7727c0: 0.00982 2] ENTER: LibGit2Sharp.Core.NativeMethods:AddHandle ()() [0x7f1d7a7727c0: 0.00987 2] LEAVE: LibGit2Sharp.Core.NativeMethods:AddHandle () [0x7f1d7a7727c0: 0.00988 1] LEAVE: LibGit2Sharp.Core.NativeMethods:.cctor () [0x7f1d7a7727c0: 0.00989 1] ENTER: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_opts (int,string)(13, [STRING:0x7f1d7a6b8130:txdv], ) [0x7f1d7a7727c0: 0.01006 2] ENTER: LibGit2Sharp.Core.StrictUtf8Marshaler:.cctor ()() [0x7f1d7a7727c0: 0.01025 3] ENTER: LibGit2Sharp.Core.StrictUtf8Marshaler:.ctor ()(this:0x7f1d78803000[LibGit2Sharp.Core.StrictUtf8Marshaler test.exe], ) [0x7f1d7a7727c0: 0.01025 3] LEAVE: LibGit2Sharp.Core.StrictUtf8Marshaler:.ctor () [0x7f1d7a7727c0: 0.01026 2] LEAVE: LibGit2Sharp.Core.StrictUtf8Marshaler:.cctor () [0x7f1d7a7727c0: 0.01027 2] ENTER: LibGit2Sharp.Core.StrictUtf8Marshaler:GetInstance (string)([STRING:0x7f1d78802ea8:40212f0c-5262-4f28-9607-f19e8e3fc16f], ) [0x7f1d7a7727c0: 0.01027 2] LEAVE: LibGit2Sharp.Core.StrictUtf8Marshaler:GetInstance (string)[LibGit2Sharp.Core.StrictUtf8Marshaler:0x7f1d78803000] [0x7f1d7a7727c0: 0.01041 2] ENTER: LibGit2Sharp.Core.EncodingMarshaler:MarshalManagedToNative (object)(this:0x7f1d78803000[LibGit2Sharp.Core.StrictUtf8Marshaler test.exe], [STRING:0x7f1d7a6b8130:txdv], ) [0x7f1d7a7727c0: 0.01059 3] ENTER: LibGit2Sharp.Core.EncodingMarshaler:FromManaged (System.Text.Encoding,string)([System.Text.UTF8Encoding:0x7f1d78802f08], [STRING:0x7f1d7a6b8130:txdv], ) [0x7f1d7a7727c0: 0.01075 3] LEAVE: LibGit2Sharp.Core.EncodingMarshaler:FromManaged (System.Text.Encoding,string)result=38389920 [0x7f1d7a7727c0: 0.01077 2] LEAVE: LibGit2Sharp.Core.EncodingMarshaler:MarshalManagedToNative (object)result=38389920 [0x7f1d7a7727c0: 0.01078 2] ENTER: LibGit2Sharp.Core.StrictUtf8Marshaler:GetInstance (string)([STRING:0x7f1d788030a8:40212f0c-5262-4f28-9607-f19e8e3fc16f], ) [0x7f1d7a7727c0: 0.01079 2] LEAVE: LibGit2Sharp.Core.StrictUtf8Marshaler:GetInstance (string)[LibGit2Sharp.Core.StrictUtf8Marshaler:0x7f1d78803000] [0x7f1d7a7727c0: 0.01085 2] ENTER: LibGit2Sharp.Core.EncodingMarshaler:CleanUpNativeData (intptr)(this:0x7f1d78803000[LibGit2Sharp.Core.StrictUtf8Marshaler test.exe], 0x249c8a0, ) [0x7f1d7a7727c0: 0.01093 3] ENTER: LibGit2Sharp.Core.EncodingMarshaler:Cleanup (intptr)(0x249c8a0, ) [0x7f1d7a7727c0: 0.01098 3] LEAVE: LibGit2Sharp.Core.EncodingMarshaler:Cleanup (intptr) [0x7f1d7a7727c0: 0.01099 2] LEAVE: LibGit2Sharp.Core.EncodingMarshaler:CleanUpNativeData (intptr) [0x7f1d7a7727c0: 0.01099 1] LEAVE: (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_opts (int,string)result=0 [0x7f1d7a7727c0: 0.01101 1] ENTER: LibGit2Sharp.Core.Ensure:ZeroResult (int)(0, ) [0x7f1d7a7727c0: 0.01102 1] LEAVE: LibGit2Sharp.Core.Ensure:ZeroResult (int) [0x7f1d7a7727c0: 0.01102 0] LEAVE: LibGit2Sharp.Core.Proxy:git_libgit2_opts_set_user_agent (string) The sample code is: using LibGit2Sharp;
class MainClass
{
public static void Main(string[] args)
{
GlobalSettings.SetUserAgent("txdv");
}
}I stepped with gdb through _opts (although without debugging symbols) and saw that the string "txdv" was duped, so I assume it did the right thing. Do you want me to implement the get functionality in libgit2? |
Sorry, something went wrong.
|
Also, do you want me to squash the whitespace fix into this same commit? |
Sorry, something went wrong.
|
Ok, I added OPT_GET_USER_AGENT libgit2 and implemented GetUserAgent in C# and it all works. I think though this should be a self contained commit, no need to add GetUserAgent here yet, since the functionality part of it gets shipped with vNext only anyway. On another note, how am I supposed to test new libgit2 functionality if all the binaries in the test directories get overwritten everytime I do a build? |
Sorry, something went wrong.
|
Great! 👍
Sure, I think that's reasonable.
libgit2 itself is included as part of the LibGit2Sharp.NativeBinaries package. There should be instructions there, but the basics are: clone the LibGit2Sharp.NativeBinaries package, update the libgit2 that you want to use, build that package and then you can set your nuget package to that. The very quick and dirty way, of course, is to overwrite the libgit2 source that's being copied. Quick and dirty, and mostly effective, but easy to mix oneself up. :) |
Sorry, something went wrong.
|
Ok, next question, if we are going to add GetUserAgent as well, shouldn't we use a getter/setter combo for this? public string UserAgent { get; set; }? |
Sorry, something went wrong.
Sure, I think that's probably fits in nicely. :) |
Sorry, something went wrong.
|
I get a SIGSEGV running the libgit2sharp tests (master) with the newest libgit2 binary (master). I did however just overwrite LibGit2Sharp.Tests/bin/Release/lib/linux/x86_64/libgit2-381caf5.so with the newest compiled one. Don't know what to really do from here. I wrote my test, but can't check if it works correctly. AFAIK it is not really possible to run one specific test with xunit 1.9.2? |
Sorry, something went wrong.
That's not unexpected; it's likely that some function changed signatures between the version that LibGit2Sharp uses and the version that you compiled.
I don't know the command line. It is possible from Visual Studio Test Explorer. |
Sorry, something went wrong.
Is there a branch which is kept up to date? |
Sorry, something went wrong.
|
What ever happened with this? |
Sorry, something went wrong.
|
I'm not sure that I know what you're asking @mj1856 - this should be merged and working in a LibGit2Sharp in the last several years. Is something not working for you? |
Sorry, something went wrong.
|
It didn't get merged. It's not in the current shipping release anyway. |
Sorry, something went wrong.
|
@ethomson - to be clear, it appears the native functionality in libgit2 was merged, but this PR to expose it in libgit2sharp was closed without merging the code. There's no functionality in libgit2sharp to set the user agent. I could use that. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
the issue is described here #1333
Do I need to write some tests for this? Without being able to get the user agent(there is only set functionality in libgit2), I don't see how it is possible to write some feasible test.
Unless I create my own http server and issue a request and take a look at the the user agent information.