|Jgit/Egit vs Git missing functionalities? [message #574818]
||Wed, 14 October 2009 13:20
| No real name
Registered: October 2009
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 19:24
| Shawn O. Pearce
Registered: July 2009
> 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 #575654 is a reply to message #574818]
||Mon, 16 November 2009 15:29
| Tomasz Prus
Registered: November 2009
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);
RevCommit revCommit = walk.lookupCommit(objectId);
TreeWalk treeWalk = TreeWalk.forPath(repository, path, revCommit.asCommit(walk).getTreeId());
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?
Powered by FUDForum
. Page generated in 0.01723 seconds