|Re: Jgit/Egit vs Git missing functionalities? [message #491548 is a reply to message #491462]
||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.
Powered by FUDForum
. Page generated in 0.06953 seconds