Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dag: diff: check CIDs in base case when comparing nodes #4767

Merged
merged 1 commit into from
Mar 23, 2018
Merged

dag: diff: check CIDs in base case when comparing nodes #4767

merged 1 commit into from
Mar 23, 2018

Conversation

schomatis
Copy link
Contributor

@schomatis schomatis commented Mar 5, 2018

The base case was assuming that the nodes were different (see issue comment).

Fixes #4591.

Copy link
Member

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

I think that we should check if the data has changed - this is still going to be sort-of broken if there are links in the node and the data is changed.

@schomatis
Copy link
Contributor Author

@whyrusleeping As you implemented ipfs object diff could you review this please?

@schomatis
Copy link
Contributor Author

I think that we should check if the data has changed - this is still going to be sort-of broken if there are links in the node and the data is changed.

@magik6k Could you elaborate more on this please? I'm not sure I follow, isn't the CID reflecting the data changes?

@schomatis schomatis changed the title [WIP] dag: diff: check CIDs in base case when comparing nodes dag: diff: check CIDs in base case when comparing nodes Mar 5, 2018
@magik6k
Copy link
Member

magik6k commented Mar 5, 2018

What I mean is that in case where the data changes in top-level node and we have some links, diff won't show any changes:

# Add some data
$ printf '{"Data":"foo"}' | ipfs object put
added QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST
$ printf '{"Data":"bar"}' | ipfs object put
added QmNeYRbCibmaMMK6Du6ChfServcLqFvLJF76PzzF76SPrZ

# Diff data without links, this works fine
$ ipfs object diff QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST QmNeYRbCibmaMMK6Du6ChfServcLqFvLJF76PzzF76SPrZ
~ QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST QmNeYRbCibmaMMK6Du6ChfServcLqFvLJF76PzzF76SPrZ ""

# Add more data, this time with links:
$ printf '{"Data":"abcd", "Links":[{"Hash":"QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST"}]}' | ipfs object put
added QmWB7VRDLSweiURLoKMtan2ZCneBXmYAHpsrbmvC8tEZav
$ printf '{"Data":"dcba", "Links":[{"Hash":"QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST"}]}' | ipfs object put
added QmdjxDJgR1hvXNSfuwWniB3DsBgv4C1SSYu6RAxwbd38H2

# Diff
$ ipfs object diff QmWB7VRDLSweiURLoKMtan2ZCneBXmYAHpsrbmvC8tEZav QmdjxDJgR1hvXNSfuwWniB3DsBgv4C1SSYu6RAxwbd38H2

# No output, we should get one like in the case without links

Note that this is also the current behaviour, not caused by the changes here, so sorry for the confusion.

@schomatis
Copy link
Contributor Author

@magik6k Thanks for the clarification, I was under the impression that the data was only reserved for the leaf nodes, not that a node could have both data and links. Yes, this was out of the scope of the original issue, but I could open a new one to discuss this further.

@whyrusleeping
Copy link
Member

LGTM, lets merge after 0.4.14 ships.

Thanks for all the PRs @schomatis :) Keep 'em coming!

@Kubuxu Kubuxu added the RFM label Mar 7, 2018
@Kubuxu Kubuxu added this to the go-ipfs 0.4.15 milestone Mar 7, 2018
@whyrusleeping whyrusleeping merged commit 64944f5 into ipfs:master Mar 23, 2018
@whyrusleeping
Copy link
Member

Three in a row!

@schomatis schomatis deleted the fix/dag/diff branch March 23, 2018 10:06
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Apr 7, 2022
dag: diff: check CIDs in base case when comparing nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants