[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Getting the difference between two related repositories

Thank you very much for your answer. It was real help!


On Tue, May 3, 2011 at 7:39 PM, Shawn Pearce <spearce@xxxxxxxxxxx> wrote:
On Tue, May 3, 2011 at 09:15, Akos Tajti <akos.tajti@xxxxxxxxx> wrote:
> I want to implement the following functionality:
> I have two git repositories (A and B). B is the clone of A. After cloning,
> some new changesets were committed to B. Now I want to find out the last
> common changeset of the two repositories. For example:
> A: a--b--c--e--f
>             |
> B:        d--g
> In this case the last common changeset is c, d and g was committed to B. Is
> there an easy way of gathering this information with JGit?

There isn't a way to do this without first fetching "f" into B, or "g" into A.

Assuming you did, you can use RevWalk with the RevFilter.MERGE_BASE
filter to find "c".

If both repositories A and B are on the local system, you might be
able to create a temporary repository T that has both A and B listed
as object alternates. This would allow you to perform the RevWalk
MERGE_BASE operation without fetching the objects between the

The network protocol that is used to exchange objects between
repositories computes a rough approximation of the common ancestor.
But it isn't accessible as a way to compute this without also doing
the transfer... and it usually comes up with at least 32 candidate
common ancestors. (Its just how the protocol works.)