Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit(Commit from where branch is created)
JGit [message #1105915] Tue, 10 September 2013 12:37 Go to next message
Ajay Gour is currently offline Ajay GourFriend
Messages: 5
Registered: September 2013
Junior Member
Using JGit library, is there a way to figure out from which commit a branch is created?

Lets say, i have below mentioned structure - A, B, C, D commits are made in master branch. From B, another branch called branch-A is created and E & F commits are made in this branch.

A -> B -> C -> D (master)
.......|
.......|--> E -> F (branch-A)

Given the example above, if i am seeing the history of branch-A, i would like it to include only E and F commits (and nothing else before first revision in branch).

Is it possible using JGit?
Re: JGit [message #1109438 is a reply to message #1105915] Sun, 15 September 2013 11:49 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
Ajay Gour skrev 2013-09-10 16.39:
> Using JGit library, is there a way to figure out from which commit a branch is created?

As the question is formulated: No. You can not see on which branch a commit is made, but (below)

> Lets say, i have below mentioned structure - A, B, C, D commits are made in master branch. From B, another branch called branch-A is created and E & F commits are made in
> this branch.
>
> A -> B -> C -> D (master)
> ......|
> ......|--> E -> F (branch-A)
>
> Given the example above, if i am seeing the history of branch-A, i would like it to include only E and F commits (and nothing else before first revision in branch).
>
> Is it possible using JGit?

RewWalk can do this for you. See LogCommand and the Log program in JGit.

RevWalk.isMergedInto can be used to see if a commit is reachable from a certain
branch. There is an heuristically optimized invocation of this method in
RevWalkUtils.findBranchesReachableFrom that you can use when you want to find all branches.

-- robin
Re: JGit [message #1110993 is a reply to message #1109438] Tue, 17 September 2013 16:07 Go to previous message
Ajay Gour is currently offline Ajay GourFriend
Messages: 5
Registered: September 2013
Junior Member
Thanks for the response Robin.

Yeah, i am aware of these methods but they dont provide commit from which branch was forked.

Anyways, we realized that GIT cannot provide the information we are looking for as it doesn't store any branch related information branch is just a label. So we are now changing our approach.

-Ajay
Previous Topic:Staging via drag-and-drop occasionally hangs forever
Next Topic:Can I disable checkout branch on mouse double click?
Goto Forum:
  


Current Time: Fri Apr 19 14:51:05 GMT 2024

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

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

Back to the top