mono / ngit Goto Github PK
View Code? Open in Web Editor NEWAutomated jgit port to c#
Automated jgit port to c#
Sharpen.Extensions.GetTotalInFixed() won't compile due to Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?) Extensions.cs 629
, which is easily fixed by changing the function body to
if( inf.TotalIn > 0 )
return Convert.ToInt32( inf.TotalIn ) + 4;
return 0;
Furrthermore I get 286 warnings, of which most seem to be very easy to fix.
I'm trying to compile the latest HEAD of the NGit repository (4ff676b) and this fails because of a missing Mono.Posix reference in the Sharpen project.
The instructions say:
"
If you are compiling on Windows using the Microsoft .NET
framework you can obtain these libraries (ICSharpCode.SharpZipLib and Mono.Security) .by installing the Mono Libraries
package: http://monodevelop.com/files/Windows/MonoLibraries.msi
"
However, there is no mention of Mono.Posix and that setup does not install any Mono.Posix library. This is the list of libraries I have in C:\Program Files (x86)\MonoLibraries\2.6:
ICSharpCode.SharpZipLib.dll
mautil.exe
Mono.Addins.CecilReflector.dll
Mono.Addins.dll
Mono.Addins.Gui.dll
Mono.Addins.Setup.dll
Mono.GetOptions.dll
Mono.Security.dll
monodoc.dll
Where can I get the correct library to add as a reference? And should the documentation change to reflect this issue?
(I'm trying to verify if #Num: #9 is actually closed by using a new version of NGit - hence the need for a compile)
Hi,
I dont know if this is a bug or just something that I am missing to configure.
When I run my MVC 4 application on IISExpress it works like a charm and clones my git repository. As soon as I switch to use regular IIS I get a "Object reference not set to an instance of an object."
Here is the stacktrace:
at Sharpen.FilePath..ctor(FilePath other, String child) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\Sharpen\Sharpen\FilePath.cs:line 25
at NGit.Util.SystemReader._SystemReader_65.OpenUserConfig(Config parent, FS fs) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Util\SystemReader.cs:line 116
at NGit.Storage.File.FileRepository..ctor(BaseRepositoryBuilder options) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Storage.File\FileRepository.cs:line 141
at NGit.BaseRepositoryBuilder2.Build() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit\BaseRepositoryBuilder.cs:line 700 at NGit.Api.InitCommand.Call() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\InitCommand.cs:line 108 at NGit.Api.CloneCommand.Init(URIish u) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\CloneCommand.cs:line 131 at NGit.Api.CloneCommand.Call() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\CloneCommand.cs:line 100 at SourceDeploy.Services.GitSourceControlManagement.Clone(String path) in d:\Projects\ToolWise\Research\SourceDeploy\SourceDeploy.Services\GitSourceControlManagement.cs:line 17 at SourceDeploy.Controllers.HomeController.Index() in d:\Projects\ToolWise\Research\SourceDeploy\SourceDeploy\Controllers\HomeController.cs:line 19 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
In order to more easily port ngit to .net-core, could we
within #IF NETFX ?
so it compiles with NETSTANDARD 2.0
As well as making the following changes
A) In Mono.Posix move Remoting to a separate dll ?
Mono.Remoting.Channels.Unix
Mono.unix -- deleted remoting
B) Mono.Posix/Mono.Unix.Native/CdeclFunction.cs
In CdeclFunction, dispose of
//this.assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (
// assemblyName, AssemblyBuilderAccess.Run);
///* MethodBuilder mb = */ tb.DefinePInvokeMethod (
// method,
// library,
// MethodAttributes.PinvokeImpl | MethodAttributes.Static | MethodAttributes.Public,
// CallingConventions.Standard,
// returnType,
// parameterTypes,
// CallingConvention.Cdecl,
// CharSet.Ansi);
//mi = tb.CreateType ().GetMethod (method);
In
\NSch\Mono.Security\Mono.Security.Protocol.Tls
remove the DebugHelper
DebugHelper.cs -- removed debug.Lisneter.add
And in
NSch\Mono.Security\Mono.Security.Protocol.Tls\HttpsClientStream.cs
somehow replace this code, or make it conditional to full .net framework.
#pragma warning disable 618
//if (ServicePointManager.CertificatePolicy != null) {
// ServicePoint sp = _request.ServicePoint;
// bool res = ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, _request, _status);
// if (!res)
// return false;
// failed = true;
//}
Added issues for Mono.Posix and Mono.Security
Maybe fork out Mono.Security until the NETSTANDARD port of Mono.Security is ready.
Also, fork out Mono.Posix from mono, as there is no nuget-library.
In case anybody needs ngit for NETSTANDARD 2.0:
https://github.com/ststeiger/ngit-core
Simple issue, probably forgot to add the new directory? It is referenced in the project file since this revision:
$git log --all -SNGit.Blame --oneline --decorate
abff6b6 (origin/master, origin/HEAD, master) Updated from JGit ---------------------------------------------------- JGit commit f1713abcdcb5097d4e448
I was looking for CopyOnWriteArrayList implementation for C# and have ended up here. Please correct your implementation - it is very dangerous if people try to use it for real things. You CANNOT lock on the object you are going to replace in same method. Create some dedicated lock object and synchronize on that. Otherwise, multiple threads can synchronize on different instances of list, losing some updates.
Additionally IndexOf is broken - you need to put reference to list into local variable at very start and use it, rather than iterating through possibly mutating 'this'.
Same for Iterator() - list reference can change between filling both arguments.
Currently when the documentation is generated for the translated C# code, <p>
tags from the javadoc comments are copied as-is to the output. These tags cause Visual Studio's IntelliSense to report an error rather than show useful information in the code completion and hover tips. There are a few possible ways to address this:
<p/>
for the XML comments.<br/>
or some other tag in the output.Just wanted to check if this has been tested under Windows. I'm running the unit tests in NGIT.Tests but I have a number of fails all in TearDown methods where it is failing to delete a file.
TearDown : NUnit.Framework.AssertionException : ERROR: Failed to delete target\trash\test1302238002145_390 in NGit.Merge.SimpleMergeTest.391
--TearDown
at NUnit.Framework.Assert.Fail(String message, Object[] args)
at NGit.Junit.LocalDiskRepositoryTestCase.ReportDeleteFailure(String testName, Boolean failOnError, FilePath e)
at NGit.Junit.LocalDiskRepositoryTestCase.RecursiveDelete(String testName, FilePath dir, Boolean silent, Boolean failOnError)
at NGit.Junit.LocalDiskRepositoryTestCase.RecursiveDelete(String testName, FilePath dir, Boolean silent, Boolean failOnError)
at NGit.Junit.LocalDiskRepositoryTestCase.TearDown()
I created a console app with NSch.dll and the required Sharpen and Mono dlls. It can connect to the SSH server (from Windows 7 to Debian), but cannot forward remote port 10080 to my local machine's port 8080. However, reverse tunneling does work: it can forward my local port 10080 to remote port 8080.
var session = jsch.GetSession("root", "192.168.1.136", 22);
session.SetPassword("password");
session.SetConfig("StrictHostKeyChecking", "no");
session.Connect();
//works. I get back the server version.
Console.WriteLine("SSH Server: " + session.GetServerVersion());
int assignedPort = session.SetPortForwardingL(8080, "192.168.1.136", 10080);
//does not work, although I properly get back the assigned port.
Console.WriteLine("Assigned Port: " + assignedPort);
//works fine.
session.SetPortForwardingR(8080, "localhost", 10080);
Is this a bug or I am doing something wrong?
Karl
Enountered an issue with Topological log rendering by latest version of ngit sources, built in VS 2010.
Given a simple history of two merged branches:
$ git log --graph --oneline
* ba81db5 Merge branch 'new'
|\
| * 7f032bd Commit #5
| * fe2dd30 Commit #3
* | efda135 Commit #4
* | 116839d Commit #2
|/
* 089e538 commit #1
I'm trying to render it in the same way using NGit using the following code:
class Program
{
static void Main(string[] args)
{
var r = new FileRepository(@"D:\temp\_git\.git");
var headId = r.Resolve(Constants.HEAD);
var rw = new RevWalk(r);
rw.Sort(RevSort.TOPO);
rw.MarkStart(rw.LookupCommit(headId));
RevCommit c;
while((c = rw.Next()) != null)
{
Console.WriteLine("{0}, {2}, {1}", c.Abbreviate(8).Name, c.GetShortMessage(), UnixTimeStampToDateTime(c.CommitTime));
}
}
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
// Unix timestamp is seconds past epoch
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}
}
Which unexpectedly gives me commit-time ordering.
ba81db55, 3/8/2013 1:16:54 PM, Merge branch 'new'
7f032bdc, 3/8/2013 1:16:05 PM, Commit #5
efda135c, 3/8/2013 1:15:29 PM, Commit #4
fe2dd30d, 3/8/2013 1:14:58 PM, Commit #3
116839d4, 3/8/2013 1:13:52 PM, Commit #2
089e5381, 3/8/2013 1:12:54 PM, commit #1
Probably there is a known issue - anyway, please let me know if it would be fixed. (I'm going to use ngit for some automation, but topo-order is critical to me).
Hey guys, sorry for the very boring title..
I'm trying to do pushes through SSH. I am specifying my own keys by using the method set out here: http://stackoverflow.com/questions/13764435/ngit-making-a-connection-with-a-private-key-file
It works well with a clone, and on the first push. After that, it fails 30% of the time, always in this method in Mono.Security:
Mono.Security.dll!Mono.Math.BigInteger.Kernel.MinusEq(Mono.Math.BigInteger big, Mono.Math.BigInteger small)
Either it fails with the message: "Error occurred during a cryptographic function", or it hangs indefinitely in this function. Again, it seems completely random whether it succeeds or not. It is being called by function in NGit:
DiffieHellmanManaged dh = new DiffieHellmanManaged (pspec.P.GetBytes (), pspec.G.GetBytes (), 0);
in GenerateKeyPair (KeyPairGenerator.cs)
Any ideas? If not, are there any ways to generate the Diffie-Helman keys through some other method?
Thanks so much -- NGit is awesome!
Cheers,
Leo
When trying to open repository on IIS NGit.Util.FS_Win32.UserHome
fails to find home folder and returns null, which causes null reference exception in NGit.Util.SystemReader.UpenUserConfig
. I'm not sure if ngit can live without user config internally, but it would be nice to have the possibility to at least redirect home folder somewhere else programatically.
[NullReferenceException: Object reference not set to an instance of an object.]
Sharpen.FilePath..ctor(FilePath other, String child) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\Sharpen\Sharpen\FilePath.cs:25
NGit.Util._SystemReader_65.OpenUserConfig(Config parent, FS fs) in E:\Projects\slluis-ngit-54a43da\NGit\NGit.Util\SystemReader.cs:116
NGit.Storage.File.FileRepository..ctor(BaseRepositoryBuilder options) in E:\Projects\slluis-ngit-54a43da\NGit\NGit.Storage.File\FileRepository.cs:141
NGit.BaseRepositoryBuilder`2.Build() in E:\Projects\slluis-ngit-54a43da\NGit\NGit\BaseRepositoryBuilder.cs:700
NGit.Api.Git.Open(FilePath dir, FS fs) in E:\Projects\slluis-ngit-54a43da\NGit\NGit.Api\Git.cs:129
NGit.Api.Git.Open(FilePath dir) in E:\Projects\slluis-ngit-54a43da\NGit\NGit.Api\Git.cs:109
I successfully compiled in Visual Studio 2010, Windows 7 x64, .NET 4.0.
Trying to run all the tests in the NGit.Test project, I randomly get an IOException when trying to delete a temporary file. Here's an example:
***** NGit.Api.CheckoutCommandTest.TestCheckoutWithNonDeletedFiles
System.IO.IOException: The process cannot access the file 'C:\Users\dprothero\Documents\GitHub\ngit\bin\target\trash\test1341438627296_62\temp' because it is being used by another process.
at Sharpen.FilePath.Delete() in C:\Users\dprothero\Documents\GitHub\ngit\Sharpen\Sharpen\FilePath.cs:line 148
System.IO.IOException: The process cannot access the file 'C:\Users\dprothero\Documents\GitHub\ngit\bin\target\trash\test1341438627296_62\Test.txt' because it is being used by another process.
at Sharpen.FilePath.Delete() in C:\Users\dprothero\Documents\GitHub\ngit\Sharpen\Sharpen\FilePath.cs:line 148
I can re-run the test and it'll pass, but another one will fail.
David
In response to
I thought I'd have a look. I used 4d686e9 and built with monodevelop 2.6 beta2 (mono 2.11 master/722f989)
ThreeTwo of the ScheduledThreadPoolExecutor unit tests intermittently fail:
The places where it asserts are:
Sharpen.Test.ScheduledThreadPoolExecutorTests.InsertDelayedTask () [0x000c1] in /tmp/ngit/Sharpen.Test/ScheduledThreadPoolExecutorTests.cs:50
Sharpen.Test.ScheduledThreadPoolExecutorTests.Shutdown () [0x00077] in /tmp/ngit/Sharpen.Test/ScheduledThreadPoolExecutorTests.cs:98
I'm not too sure whether it's just racey test cases, or that there is a fundamental problem. However, since the asker on Stack Overflow was experiencing shutdown problems with threads waiting around forever, I thought I'd report this just in case.
Cheers,
Seth
Using NGit (or even JGit since it's a port) does anyone know how to respond to the Git clone command over Smart HTTP? What would the sample code look like?
I can't find any references or documentation which describes this.
I'm trying to create a .NET GIT server to handle simple clone, push and pull requests.
Any help is appreciated.
It would be great if ICSharpCode.SharpZipLib.dll was also included in the git source code repository, so we don't need to search and download the library.
I have another set of tests failing on Windows.
NGit.Api.ApplyCommandTest.TestAddA1:
NGit.Errors.InvalidObjectIdException : Invalid id : de98044
NGit.Api.ApplyCommandTest.TestAddA2:
NGit.Errors.InvalidObjectIdException : Invalid id : de98044
NGit.Api.ApplyCommandTest.TestDeleteD:
NGit.Errors.InvalidObjectIdException : Invalid id : 0000000
Those are throwing an IndexOutOfRangeException in RawParseUtils.ParseHextInt32, which FromHexString catches and rethrows as an InvalidObjectIdException
Then, the remaining tests in NGit.Api.ApplyCommandTest are failing with a different error:
NGit.Api.ApplyCommandTest.TestModifyE:
System.ArgumentException : Illegal characters in path.
NGit.Api.ApplyCommandTest.TestModifyX:
System.ArgumentException : Illegal characters in path.
NGit.Api.ApplyCommandTest.TestModifyY:
System.ArgumentException : Illegal characters in path.
NGit.Api.ApplyCommandTest.TestModifyY:
System.ArgumentException : Illegal characters in path.
These are getting kicked out of the FilePath constructor from this line: this.path = Path.Combine (other, child);
For TestModityE, for example, other == "C:\Users\dprothero\Documents\GitHub\ngit\bin\target\trash\test1341691177321_542"
and child == "E\r"
I'm assuming it doesn't like the backslash?
I'm still way too new to the codebase to be able to see what is going on with these issues.
The NGit.Transport.HttpTransport.IsSmartHttp method performs a direct equality comparison between an expected content-type header value and the actual one.
However, some HTTP servers append a charset value at the end of the content-type header, which confuses the equality check.
For instance, "application/x-git-upload-pack-advertisement; charset=utf-8" is still valid Smart-HTTP, but because it does not equal "application/x-git-upload-pack-advertisement", IsSmartHttp returns false.
This is reproducible for the AppHarbor.com service and repositories hosted by Git Web (http://gitweb.codeplex.com).
Exception: "[email protected]:username/project.git: Algorithm negotiation fail"
Code:
public class CustomConfigSessionFactory : JschConfigSessionFactory
{
public string PrivateKey { get; set; }
public string PublicKey { get; set; }
protected override void Configure(OpenSshConfig.Host hc, Session session)
{
var config = new Properties();
config["StrictHostKeyChecking"] = "no";
config["PreferredAuthentications"] = "publickey";
session.SetConfig(config);
var jsch = this.GetJSch(hc, FS.DETECTED);
jsch.AddIdentity("KeyPair", Encoding.UTF8.GetBytes(PrivateKey), Encoding.UTF8.GetBytes(PublicKey), Encoding.UTF8.GetBytes("netbrain"));
}
}
var customConfigSessionFactory = new CustomConfigSessionFactory();
customConfigSessionFactory.PrivateKey = File.ReadAllText(@"D:\id_rsa");
customConfigSessionFactory.PublicKey = File.ReadAllText(@"D:\id_rsa.pub");
NGit.Transport.JschConfigSessionFactory.SetInstance(customConfigSessionFactory);
var git = NGit.Api.Git.CloneRepository()
.SetDirectory(new Sharpen.FilePath(@"d:\abcde"))
.SetURI("[email protected]:username/project.git")
.Call();
ngit2, clone command, win10, .net4.5 vs2017 pro
WebException: The request was aborted: Could not create SSL/TLS secure channel
at Sharpen.HttpURLConnection.get_Response()
at Sharpen.HttpURLConnection.GetResponseCode()
at NGit.Util.HttpSupport.Response(HttpURLConnection c)
at NGit.Transport.TransportHttp.Connect(String service)
at NGit.Transport.TransportHttp.OpenFetch()
at NGit.Transport.FetchProcess.ExecuteImp(ProgressMonitor monitor, FetchResult result)
at NGit.Transport.FetchProcess.Execute(ProgressMonitor monitor, FetchResult result)
at NGit.Transport.Transport.Fetch(ProgressMonitor monitor, ICollection`1 toFetch)
at NGit.Api.FetchCommand.Call()
at NGit.Api.CloneCommand.Fetch(Repository clonedRepo, URIish u)
at NGit.Api.CloneCommand.Call()
at WebApplication1.WebForm1.kk() in C:\Users\myu\source\repos\WebApplication1\WebApplication1\WebForm1.aspx.cs:line 25
at WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Users\myu\source\repos\WebApplication1\WebApplication1\WebForm1.aspx.cs:line 16
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I've been unable to use NGit since updating my SharpZipLib (required by another project) to the latest version from Nuget - it throws a MissingFieldException.
I've got it working by forking (https://github.com/mcintyre321/ngit) and updating SharpZipLib , updating, then recompiling, but it would be great if the version on Nuget was up to date.
It would appear that the ciphers provided in the current version are not being kept up to date.
The current ciphers align with JSCH-0.1.46 and these are no longer supported by many major providers (eg Bitbucket).
We need to update the Jsch ciphers in this library to support the newer KEXs
i am new with ngit..
i use the code blow:
CloneCommand clone = Git.CloneRepository();
clone.SetURI("git://github.com/jquery/jquery.git").
SetDirectory(@"D:\localRepository").
Call();
it throw an exception...
so ,i want to know, how to clone a remote repository with ngit api..
thanks..
If I build with xbuild everything works fine.
However if I use MonoDevelop it shows errors like:
error CS1061: Type System.Collections.ArrayList' does not contain a definition for
RemoveElement' and no extension method RemoveElement' of type
System.Collections.ArrayList' could be found (are you missing a using directive or an assembly reference?)
The .NET Framework HttpWebRequest.GetResponse() throws a WebException when the response's status code is HTTP 401. The actual response is contained in the Exception.
However, the getter of the Response property of HttpURLConnection does not try to catch this type of exception, which results in an unhandled WebException when HTTP authorization fails, instead of the expected JGitInternalException.
My application needs to call setProperty() to override "jgit.gitprefix" before using NGit. But current Sharpen.Runtime class is declared as internal which only visible to NGit.
Hello,
I noticed RmCommand doesn't contain the cached option in NGit. I researched if its implemented in JGit(so i send a patch if its not), but it was implemented. Maybe only regenerating the NGit code is needed or?
hi
i got a exception when call clone command, can you help it?
StackTrace:
at Sharpen.HttpURLConnection.GetResponseCode() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\Sharpen\Sharpen\HttpURLConnection.cs:line 177
at NGit.Util.HttpSupport.Response(HttpURLConnection c) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Util\HttpSupport.cs:line 264
at NGit.Transport.TransportHttp.Connect(String service) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Transport\TransportHttp.cs:line 509
at NGit.Transport.TransportHttp.OpenFetch() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Transport\TransportHttp.cs:line 291
at NGit.Transport.FetchProcess.ExecuteImp(ProgressMonitor monitor, FetchResult result) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Transport\FetchProcess.cs:line 126
at NGit.Transport.FetchProcess.Execute(ProgressMonitor monitor, FetchResult result) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Transport\FetchProcess.cs:line 104
at NGit.Transport.Transport.Fetch(ProgressMonitor monitor, ICollection`1 toFetch) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Transport\Transport.cs:line 1226
at NGit.Api.FetchCommand.Call() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\FetchCommand.cs:line 139
at NGit.Api.CloneCommand.Fetch(Repository repo, URIish u) in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\CloneCommand.cs:line 163
at NGit.Api.CloneCommand.Call() in C:\Users\Administrator\Desktop\ngit-xpaulbettsx\NGit\NGit.Api\CloneCommand.cs:line 101
at ConsoleApp1.Class2.kk() in C:\Users\myu\source\repos\ConsoleApp1\ConsoleApp1\Class2.cs:line 13
at ConsoleApp1.Program.Main(String[] args) in C:\Users\myu\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 54
My code is easy:
var clone = NGit.Api.Git.CloneRepository();
clone.SetDirectory(new Sharpen.FilePath(@"d:\abcde"));
clone.SetURI("https://github.com/xxxx/xxxx.git");
//clone.SetCredentialsProvider(new UsernamePasswordCredentialsProvider("xxxx", "xxxx"));
clone.Call(); ------ throw exception
my system is window 10 Pro N, visual studio 2017 pro, .net 4.5 ngit1.0
thank you
This is the code I'm currently using:
JSch jsch = new JSch();
jsch.AddIdentity("/path/to/mykey");
Session session = jsch.GetSession("someuser", "somehost");
Hashtable table = new Hashtable();
table["StrictHostKeyChecking"] = "no";
table["PasswordAuthentication"] = "no";
table["ChallengeResponseAuthentication"] = "no";
table["X11Forwarding"] = "no";
table["BatchMode"] = "no";
session.SetConfig(table);
session.Connect();
session.Disconnect();
On the server side I get this:
Oct 31 22:30:21 somehost sshd[12841]: error: RSA_public_decrypt failed: error:0407006A:lib(4):func(112):reason(106)
This is using an RSA key, I tried using DSA as well and it doesn't work either. Using ssh -i /path/to/key somehost works fine.
I am trying to use IsClean() to determine if the remote repository has changed or not but when I try to use IsClean() it always return true when I change the remote repo (when I change file in local repo it returns false, that means it works for this case). Is there any problem with this particular function or am I missing something.
var repository = Git.Open(C:\git);
while (repository.Status().Call().IsClean())
{
repository.Pull().Call(); // this function change the repo status
Console.WriteLine("Is clean");
}
BatchingProgressMonitor's alarmQueue is preventing application exit with NGit.
The destructor of _object_87 is never called, causing the thread pool (alarmQueue in BatchingProgressMonitor) to hang indefinitely.
I have proof-of-concepted a workaround based on calling alarmQueue.ShutdownNow() explicitely, see here
Minimal failing example:
using System;
using NGit;
using NGit.Api;
using NGit.Transport;
namespace Stacko
{
class MainClass
{
public static void Main (string[] args)
{
Git myrepo = Git.Init().SetDirectory(@"/tmp/myrepo.git").SetBare(true).Call();
{
var fetchResult = myrepo.Fetch()
.SetProgressMonitor(new TextProgressMonitor())
.SetRemote(@"/tmp/initial")
.SetRefSpecs(new RefSpec("refs/heads/master:refs/heads/master"))
.Call();
//
// Some other work...
//
myrepo.GetRepository().Close();
}
System.GC.Collect();
#if false
System.Console.WriteLine("Killing");
BatchingProgressMonitor.ShutdownNow();
#endif
System.Console.WriteLine("Done");
}
}
}
using the helper in BatchingProgressMonitor:
public static void ShutdownNow()
{
alarmQueue.ShutdownNow();
}
Tested platforms:
last commit here is several years old
git://git.eclipse.org/gitroot/jgit/jgit.git
have newer versions like
JGit v4.0.0.201506090130-r
Contained in tags: v4.0.0.201506090130-r
Commit hash: 4f221854556991e3394b3a71e77ee0b771b1500b
Date: 2 weeks ago (09.06.2015 8:29:27)
see also
gitextensions/gitextensions#2516
earlier attempt:
https://github.com/henon/GitSharp
slluis:
"The really hard parts are:
Some of those problems could be alleviated by improving Sharpen, but only to some extent, since there are some Java constructs which are not easily translatable to C# (and JGit uses many of them)."
https://github.com/pvginkel/gitter/issues/15
NGit does not provide a Stage function which would make deleted files be marked as staged deletes.
mono/monodevelop#653
GPL/LGPL questions with Sharpen.Unix
mono/sharpen#39
weak documentation
#13
I think it should be possible to run JGit on mono directly with ikvm, but can't find posts about it.
UPD:
https://github.com/mono/jgit-binary
http://tirania.org/blog/archive/2009/Oct-12.html
The GetDirectory() method of the ObjectDirectory class is set as internal: https://github.com/mono/ngit/blob/master/NGit/NGit.Storage.File/ObjectDirectory.cs#L151
But it should be public:
http://git.eclipse.org/c/jgit/jgit.git/tree/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java#n172
Also applies for fileFor(AnyObjectId).
I need this methods for some tasks.
I am currently using this (very very dirty) Workaround:
string path = objectDirectory.ToString();
path = path.Substring(16, path.Length - 17);
ToString() delivers "ObjectDirectory[" + GetDirectory() + "]". That way it's possible to extract the path.
Current implementation of Sharpen.FilePath constructor and java.io.File behave differently. Especially in Windows.
"C:", "\ABC\DEF" combines the wrong path
We may refer to the java test to match the behaviour
http://hg.openjdk.java.net/build-infra/jdk7/jdk/raw-file/00cd9dc3c2b5/test/java/io/File/Cons.java
but we also need to consider backward slash "" which is not covered by java test
As currently NGit doesn't support cloning with http/https I made some changes to Sharpen and JGit to support it.
Here are the new commits:
zahhak/jgit@2a837bf
zahhak@c812122
What do you think about them?
While trying to write some NGit related tests I always get UnauthorizedAccessExceptions
when trying to delete my repo path after creating it.
is there a way to release any pack file locks?
running
repo.GetRepository().Close();
doesn't seem to fix things.
Projects reference libs (ICSharpCode.SharpZipLib, Mono.Security, Nunit) that cannot be found. I suggest putting these dependencies in a \lib folder. I will do a PR if you concur.
if you do:
var keyPair = NSch.KeyPair.GenKeyPair(jsch, NSch.KeyPair.RSA, 1024);
you get a casting exception:
Unable to cast object of type 'Sharpen.RSAPrivateKey' to type 'Sharpen.RSAPrivateCrtKey'.
I'm going to try and clone and fix the bug, but I'm just wanting to check i'm calling it correctly?
How do you use Ngit with a public/private ssh keypair?
I can't seem to find documentation anywhere, and the framework's not throwing me any hints.
Sometimes, communication with the server fails. When this happens, a NullReferenceException in DiffieHellmanManaged.Dispose on the finalizer thread brings down the process.
The NullReferenceException in itself is not a problem. However, that it happens on the finalizer thread is. It looks like adding a using in Sharpen.DHKeyPairGenerator should solve this issue.
I want to create a bundle with the BundleWriter class. I can add branches to the bundle, but adding the current HEAD (which is neccesary to actually pull from a bundle) does not work. The following code
using System;
using NGit;
using NGit.Storage.File;
using NGit.Transport;
public static class M
{
static void Main()
{
string workingDir = "/tmp/gittestdir";
var repository = new FileRepository(workingDir);
var bundleWriter = new BundleWriter(repository);
Ref head = repository.GetRef("HEAD");
bundleWriter.Include(head);
}
}
throws an exception:
Unhandled Exception: System.ArgumentException: Invalid ref name: HEAD
at NGit.Transport.BundleWriter.Include (System.String name, NGit.AnyObjectId id) [0x00000] in <filename unknown>:0
at NGit.Transport.BundleWriter.Include (Ref r) [0x00000] in <filename unknown>:0
at M.Main () [0x00000] in <filename unknown>:0
This project really needs a wiki with examples how to get basic remote operations to work, and perhaps some very basic examples.
Have been searching and trying to get NGit to work with Clone, Fetch and Push using ssh with a private key file, for the last 3 days without luck. Is here any places where such examples exists? - have looked through many of the tests without any luck as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.