go-git icon indicating copy to clipboard operation
go-git copied to clipboard

fix "reference delta not found" when cloning from aws codecommit

Open kcburge opened this issue 5 years ago • 6 comments

The existing code does not handle the case where a ref delta refers to another deltified object. Once the "parent" was undeltified, not attempt was made to resolve references to that object's SHA1.

This change simply checks to see if there is an ExternalRef to the object just resolved, and if so, replaces it and adopts its children.

I'm not an expert in the bowels of git, but this fixed my inability to clone from codecommit.

kcburge avatar Mar 12 '19 14:03 kcburge

Thanks for the patch!

@kcburge, are you able to iterate over all the objects after that change? I believe this change fixes index creation but there may be more problems.

jfontan avatar Mar 14 '19 11:03 jfontan

I have not thoroughly tested the cloned repository. I am using this for (currently) read only build automation. I have yet to try to make any changes to the cloned repo. Haven't even tested subsequent pull either.

I don't know the inner workings of git, but this was clearly a problem, so I attempted the fix.

On Thu, Mar 14, 2019, 06:31 Javi Fontan [email protected] wrote:

@kcburge https://github.com/kcburge, are you able to iterate over all the objects after that change? I believe this change fixes index creation but there may be more problems.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/src-d/go-git/pull/1086#issuecomment-472813151, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcc9SHApoTdn-HU_wVYf2dVwrdak2oHks5vWjL1gaJpZM4brATR .

kcburge avatar Mar 16 '19 14:03 kcburge

I resolved the DCO issue. I apologize for not having time to resolve the codecov issue.

kcburge avatar Apr 21 '19 20:04 kcburge

@kcburge can you provide a test?

mcuadros avatar Apr 22 '19 14:04 mcuadros

I don't have anything to test with - I ran into this issue pulling from AWS codecommit (and not all repositories had this issue -- which is not invalid behavior of Git). It has been quite a while since I thought about this, but, from what I recall, the packfile objects parsed in order like this:

Object 1 OBJ_BLOB Object 2 OBJ_REF_DELTA (based on Object 1) Object 3 OBJ_REF_DELTA (based on Object 2) <-- this is where it would blow up

Basically the second (and more) subsequent ref delta's referred to SHA1's that didn't exist until the prior ref deltas were resolved. I don't know how hard it would be to mock this data structure.

Sorry I can't be more helpful at this time.

kcburge avatar Apr 22 '19 16:04 kcburge

What you can do upload to go-git-fixture a copy of the packfile or the capture the HTTP response to create a fixture.

mcuadros avatar Apr 22 '19 22:04 mcuadros