Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Using InMemoryRepository

cool. thanks Dave.
This will save me a lot of time :)
Regards
Monmohan

On Tue, Mar 31, 2015 at 2:06 AM, Dave Borowitz <dborowitz@xxxxxxxxxx> wrote:
It's clear by now that InMemoryRepository is likely not what you need, but I will just mention that, for tests at least, there is a succinct way to do porcelain-ish things on bare repositories: TestRepository. It has a little fluent API that implements a subset of git commands that are guaranteed to work with bare repositories (it's tested against InMemoryRepository).

To make a single commit to master adding a file foo.txt:

TestRepository<InMemoryRepository> tr = new TestRepository<>(
    new InMemoryRepository(new DfsRepositoryDescription("test"));
tr.update("refs/heads/master").commit()
    .add("foo.txt", "contents of foo.txt")
    .create();

On Sat, Mar 28, 2015 at 5:58 PM, Monmohan Singh <monmohan@xxxxxxxxx> wrote:
So for adding and commiting a file to inmemrepo, one would have 
1) Insert the object
2) update the index
3) create the tree and commit
4) update the refs

Is that correct? Or is there an easier way to go about this?

Any particular reason that setting a work tree is not supported for such a repository ?

Regards
Monmohan


 

On Sat, Mar 28, 2015 at 8:27 PM, Alex Blewitt <alex.blewitt@xxxxxxxxx> wrote:
The porcelain commands assume a File basis in some cases, particularly when it comes to the working tree. You can perform inserts into an in-memory repository if you do the work yourself, but the porcelain commands do not work in that way.

Alex

On 28 Mar 2015, at 11:12, Monmohan Singh <monmohan@xxxxxxxxx> wrote:

Thanks for the response.
Even if that was the case, shouldn't it support the case where a file can be added and committed to the repos (which in turn would create object, tree, commit refs etc. in memory)? 

Regards
Monmohan

On Sat, Mar 28, 2015 at 5:56 PM, Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:
On Sat, Mar 28, 2015 at 10:32 AM, Monmohan Singh <monmohan@xxxxxxxxx> wrote:
Hi,
When using FileRepository, I see we can use JGit porcelain equivalent of Git commands like add file, commit etc. 
But there doesn't seem a way to set a WorkTree for InMemoryRepository. My understanding was that this (in-memory) storage is equivalent of .git folder in case of FileRepository .  What is the way to add files to such a repo, using ObjectInserter?

Thanks in advance for the help :) 

AFAIK InMemoryRepository is only used by tests. See DfsInserterTest for some examples.

-Matthias 

_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jgit-dev



_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jgit-dev



Back to the top