Open lak opened 5 years ago
Hi @lak - we've gone back and forth about this. You're right it's confusing when you first try it.
You can get the behavior you want, by saying:
noms diff jsondb::#bc2vr3i95nn47n5dagol2cm0k9543opf.value jsondb::#mpvtg5ng1vjokafas1nrir8c9hpsqovn.value
That is, ask noms to just compare the value of the commits, not the commit objects themselves.
I think that when diffing commits, the user typically wants the behavior you ask for. But the challenge is that noms diff
can diff any value in the database, not just commits. So making it special case commits is a bit weird, especially when you consider that as a user you can just create a struct with name Commit
. Should we special case when you diff that?
Git special-cases commits to make the output prettier in this case, but git doesn't have the problem of users writing arbitrary objects to its database.
I wonder if we had auto-complete, if this would feel less cumbersome.
I expect there are ways to make this less confusing.
But IMO including non-content differences by default is a bad choice. If you claim idempotency, then the core tools should exhibit it by default. Yes, you could get non-idempotent behavior (e.g., showing different parents and dates) but you would have to pick it.
Yeah, I suppose I could imagine a --compare-commit-values
that defaults to true
which means to only compare the .value
struct of any Commit
object.
It's a bit unfortunate to have the special case, but maybe worth it since this is a common case.
PS: I believe that having json-import
auto-commit in the first place was a bug, and it has since been changed. noms commit
won't commit a duplicate value by default. So with the current version of both programs, you wouldn't have run into this as easily.
I'm experimenting with json-import, and getting some surprising behavior.
I would expect that two datasets would show no diff, but noms seems to consider different parents to indicate different data sets. IMO, the parentage is an aspect of the database, not of the data itself, and thus should not be in diff output.
Note that the text below also shows date in the meta; I don't know whether this is an artifact of json-import, or noms diff. If the latter, then I would also expect that not to be shown. Of course two different commits are going to have different dates and parents, so these should be skipped.