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

plumbing: format/packfile, fix crash with cycle deltas #731

Merged
merged 2 commits into from
Jan 25, 2018

Conversation

jfontan
Copy link
Contributor

@jfontan jfontan commented Jan 24, 2018

Resolving cycles relied on ObjectToPack objects having Original. This is no longer true with the changes from #720. This commit changes:

  • Save original type, hash and size in ObjectToPack
  • Use SetObject to set both Original and resolved type, hash and size
  • Restore original object before using BackToOriginal (cycle resolution)
  • Update encoder test to check this case

Resolving cycles relied on ObjectToPack objects having Original. This
is no longer true with the changes from src-d#720. This commit changes:

* Save original type, hash and size in ObjectToPack
* Use SetObject to set both Original and resolved type, hash and size
* Restore original object before using BackToOriginal (cycle resolution)
* Update encoder test to check this case

Signed-off-by: Javi Fontan <jfontan@gmail.com>
// SetOriginal sets both Original and saves size, type and hash
func (o *ObjectToPack) SetOriginal(obj plumbing.EncodedObject) {
o.Original = obj
o.originalSize = obj.Size()
Copy link
Contributor

Choose a reason for hiding this comment

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

check if obj is nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added checks to SetOriginal and BackToOriginal. The test now also uses it to set Original to nil.

SetOriginal now skips setting resolved values if the provided
object is nil. BackToOriginal also skips nil Original objects.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
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.

3 participants