Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] GIT replace

Thanks :) I will try to find some time to look into this.

-----Original Message-----
From: Shawn Pearce [mailto:spearce@xxxxxxxxxxx]
Sent: Thursday, September 28, 2017 5:33 PM
To: Duft Markus <Markus.Duft@xxxxxxxxxxxxxxxx>
Cc: JGit Developers list (jgit-dev@xxxxxxxxxxx) <jgit-dev@xxxxxxxxxxx>
Subject: Re: [jgit-dev] GIT replace

On Wed, Sep 27, 2017 at 10:29 PM, Duft Markus
<Markus.Duft@xxxxxxxxxxxxxxxx> wrote:
>
> We are thinking about splitting out repositories history, as it is getting
> quite large recently. To allow history browsing for our developers, we will
> provide a script that ‘git replace’s the old history onto the new repo.
> Unfortunately it seems that JGIT does not support reading git replace refs.
> Now my question to the experts: Do you think this is much effort to
> implement? I do not need to be able to use git replace from the IDE, but the
> history view and annotations in the editor should show the replaced history…
>
>
>
> I am willing to give it a shot and try to implement it if I get some hints
> on how/where to start J

Replace is a bit challenging because the reader needs to scan the
refs/replace/ namespace before it does anything. That scan has to
build up a mapping table to quickly map an ObjectId to its
replacement, so that individual object accesses can be checked against
the map.

I think this logic winds up in the ObjectReader. So an ObjectDatabase
implementation needs to check if there are refs/replace/ in its
sibling RefDatabase, build an ObjectIdOwnerMap to maintain the mapping
of old -> replace, and pass this mapping to any ObjectReader it makes.

ObjectReader's methods like open() and has() need to consult the
mapping, and if a replace entry exists, swap the caller's AnyObjectId
with the replacement id before proceeding to locate the object in the
ObjectDatabase.

IIRC PackWriter falls into a weird corner case where by default its
not supposed to honor refs/replace/. So you also need a flag on the
ObjectReader that allows a caller to disable/clear the replacement
mapping and let PackWriter set this on any ObjectReader its using to
ensure its packing the original graph and not the replacement
structure.

SSI Schäfer IT Solutions GmbH | Friesachstrasse 15 | 8114 Friesach | Austria
Registered Office: Friesach | Commercial Register: 49324 K | VAT no. ATU28654300
Commercial Court: Landesgericht für Zivilrechtssachen Graz

Back to the top