Biblioteca .Net Git que permite agregar / modificar archivos en la memoria

Does anyone know of a Git library for C# that allows client code to add & modify repository files in memory? I have a bare repository that I would like to make additions and modifications to pragmatically. Because it is a bare repository I do not want to write files to the file system. Does something like this exists?

¡Gracias!

preguntado el 30 de enero de 12 a las 19:01

2 Respuestas

GitSharp expone un Create() overload on its Blob type which allows a direct write to the Git Object database without the need for an intermediate file in a Working Directory.

The unit test below (slightly patched from BlobTests.cs) demonstrates such feature:

[Test]
public void WriteBlob()
{
    using (var repo = GetTrashRepository())
    {
        blob = Blob.Create(repo, "and this is the data in me\r\n\r\n");
        Assert.AreEqual("95ea6a6859af6791464bd8b6de76ad5a6f9fad81", blob.Hash);

        var same_blob = new Blob(repo, blob.Hash);
        Assert.AreEqual(Encoding.UTF8.GetBytes("and this is the data in me\r\n\r\n"), same_blob.RawData);
    }
}

EDIT:

You might also be willing to take a look at NGit. It's an automated port of JGit to .Net. Contrarily to GitSharp, it is still maintained.

La ObjectInserter (consulte aquí) parece something promising.

Nota: If you're willing to use Git as an object database, by directly writing objects without the Commit dance, make sure to create a reference (in .git/refs) to prevent them from being pruned upon a git gc lanzamiento.

Nota 2: Git objects are read only, so you won't be able to "modify" a Blob. However, if you created a reference pointing at it, you can create a new "updated" Blob, and change the target of the reference to point at the new "version".

Respondido 04 Feb 12, 18:02

A bare repository IS on the file system. If you would like some fast in-memory manipulation, use a ram disk. This way you still get the up-to-date functionality of git.

Respondido el 31 de enero de 12 a las 00:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.