Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plumbing: format/packfile, fix panic retrieving object hash. #744

Conversation

jfontan
Copy link
Contributor

@jfontan jfontan commented Feb 9, 2018

In some cases the original data is not saved before it is cleaned and forces a panic when it's retrieved.

The change adds ObjectToPack.CleanOriginal to be used to clean original object instead of:

object.Original = nil

Now when the Original data is freed because it's no longer in the pack window a SetOriginal call is done to make sure that Size, Hash and Size data is not lost.

Fixes src-d/borges#229

In some cases the original data is not saved before it is cleaned
and forces a panic when it's needed.

The change adds ObjectToPack.CleanOriginal to be used to clean original
object instead of:

    object.Original = nil

Now when the Original data is freed because it's no longer in the pack
window a SetOriginal call is done to make sure that Size, Hash and Size
data is not lost.

Signed-off-by: Javi Fontan <[email protected]>
@@ -231,7 +231,8 @@ func (dw *deltaSelector) walk(
delete(indexMap, obj.Hash())

if obj.IsDelta() {
obj.Original = nil
obj.SetOriginal(obj.Original)
obj.CleanOriginal()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little bit strange, maybe is worth it to add a method that just add the original metadata to the objectToPack, something like obj.SetOriginalMetadata(obj.Original)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've adede a SaveOriginalMetadata function. It uses current Original object.

@mcuadros mcuadros merged commit 01c428c into src-d:master Feb 13, 2018
jfontan added a commit to jfontan/borges that referenced this pull request Mar 28, 2018
It fixes some panics retrieving object hashes

src-d/go-git#744

Signed-off-by: Javi Fontan <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants