Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Jgit/Egit vs Git missing functionalities?
Jgit/Egit vs Git missing functionalities? [message #574818] Wed, 14 October 2009 17:20 Go to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: October 2009
Junior Member
Hello!

I am a jgit/egit newbie and this is my first post so please be gentle. :blush:

I want to integrate a git repository in my development. I'll try to explain better: I don't want to use git as a repository for my development, I want that my application stores (add & commit) files using git and be able to recover old revisions. In addition to that I also need clone/push/pull functionality.

In order to know if git is appropiate for my needs I have been using Git from the command line to do some preliminary test. It worked OK and gave me all the functionality I needed.

When I started using jgit (and some egit functionality) in my development I noticed that, at least from egit, I couldn't perform some actions I needed. So I have 4 main questions:

1) Is it possible to perform PULL action (git fetch + git merge)?

2) How can I control, if possible, which merge strategy to use with each commiting file?

3) Is it possible to go back to a history revision without overwriting all the tree that is between the head and the wanted revision?

4) Are there any plans to implement all the functionality of git in jgit/egit? Where can I look for it?

Thank you very much in advance!

P.S: Maybe this is not the right place to post this questions. In that case, sorry!
Re: Jgit/Egit vs Git missing functionalities? [message #574838 is a reply to message #574818] Wed, 14 October 2009 23:24 Go to previous messageGo to next message
Shawn O. Pearce is currently offline Shawn O. PearceFriend
Messages: 82
Registered: July 2009
Member
javier.manso@techideas.es wrote:
> When I started using jgit (and some egit functionality) in my
> development I noticed that, at least from egit, I couldn't perform some
> actions I needed. So I have 4 main questions:

JGit is more complete than EGit's UI exposes, but JGit is also missing
some features that exist within the command line C git implementation.

> 1) Is it possible to perform PULL action (git fetch + git merge)?

Fetch, yes, open a Transport object and use its fetch method.

Merge, eh, sort of. There is a start of a merge API available through
the MergeStrategy and Merger interfaces. There is a simple strategy
called SIMPLE_TWO_WAY_IN_CORE which can perform a merge in memory by
resolving paths where only one side has made an edit.

So SIMPLE_TWO_WAY_IN_CORE can handle the case where branch A modifies
file A.txt and branch B modifies B.txt just fine. It fails on merges
where both branches modify the same file, *even if* that merge would be
resolved automatically by the C git implementation.

A problem with this current API is it doesn't report where there are
conflicts, which makes it harder for the application to then define its
own merge strategy...

> 2) How can I control, if possible, which merge strategy to use with each
> commiting file?

You can't, yet. You'd essentially have to do the merge operation
completely yourself. You can read the source code of
StrategySimpleTwoWayInCore to see how one might go about doing this, but
it needs to be easier, its unreasonable to ask applications to implement
this logic themselves.

> 3) Is it possible to go back to a history revision without overwriting
> all the tree that is between the head and the wanted revision?

Sure, just use RevWalk to help you find that older revision, and once
you know the commit get its RevTree via RevCommit.getTree() and then go
ask a TreeWalk for the relevant file paths. Take those ObjectIds and
ask for their objects from the Repository... and there is your old content.
Re: Jgit/Egit vs Git missing functionalities? [message #574854 is a reply to message #574818] Thu, 15 October 2009 08:00 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: October 2009
Junior Member
Thank you very much for your answer!
I think they are really useful for me!
Re: Jgit/Egit vs Git missing functionalities? [message #575654 is a reply to message #574818] Mon, 16 November 2009 20:29 Go to previous message
Tomasz Prus is currently offline Tomasz PrusFriend
Messages: 2
Registered: November 2009
Junior Member
Hi,

1) Is this a proper way to load repository content for path and for particular revision?

AnyObjectId objectId = repository.resolve(revision);

RevWalk walk = new RevWalk(repository);
walk.markStart(walk.parseCommit(objectId));

RevCommit revCommit = walk.lookupCommit(objectId);
TreeWalk treeWalk = TreeWalk.forPath(repository, path, revCommit.asCommit(walk).getTreeId());

treeWalk.setRecursive(true);
treeWalk.setFilter(TreeFilter.ALL);

ObjectId fileObjectId = treeWalk.getObjectId(0);
ObjectLoader objectLoader = repository.getObjectDatabase().openObject(new WindowCursor(), fileObjectId);

System.out.println("tu: " + new String(objectLoader.getBytes()));

2) How can i check if it's file or directory and then return directory structure?

3) How can i check if loaded file is text or binary?

Best regards,
Tomasz Prus
Previous Topic:CommitAction class - access restrictions
Next Topic:Jgit/Egit vs Git missing functionalities?
Goto Forum:
  


Current Time: Thu Mar 28 08:04:17 GMT 2024

Powered by FUDForum. Page generated in 1.02546 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top