git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: David Abrahams <dave@boostpro.com>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	Michael Witten <mfwitten@gmail.com>,
	Daniel Barkalow <barkalow@iabervon.org>,
	Jeff King <peff@peff.net>, Johan Herland <johan@herland.net>,
	git@vger.kernel.org, "J. Bruce Fields" <bfields@fieldses.org>
Subject: Re: [doc] User Manual Suggestion
Date: Sun, 26 Apr 2009 19:56:13 +0200	[thread overview]
Message-ID: <20090426175613.GA4942@atjola.homenet> (raw)
In-Reply-To: <FA5C0FFA-2DCD-4DF1-9A94-C2A26A9DCAE9@boostpro.com>

On 2009.04.26 09:55:34 -0400, David Abrahams wrote:
>
> On Apr 26, 2009, at 7:28 AM, Björn Steinbrink wrote:
>
>> On 2009.04.25 15:36:24 -0400, David Abrahams wrote:
>>> Where it's relevant when the user notices that two distinct files
>>> have the same id (because they happen to have the same contents) and
>>> wonders what's up.
>>
>> Why would the user have to care about the object files in the repo?
>
> What a strange question. I have no idea how to answer. It seems
> self- evident to me that users of a VCS care that their files are
> stored in it.

_Their_ files. The files that come from/end up in the working tree. I
cared about those when I used SVN, too. But I never went to the SVN repo
to find out if there are two equal files in it. We're talking about
object names, and those belong to objects, not files in the working
tree.

>> And why would your implementation save the same object twice, in two
>> distinct files?
>
> One could easily have the expectation that contents can be duplicated  
> because there are numerous precedents in everyone's experience of  
> computing, for example in filesystems and in any programming language  
> that is not pure-functional.

That's not answering my question. I asked why you come up with an
implementation that is "broken" enough to save the same object twice
with different file names.  If the implementation does not do that, your
"when the user notices that two distinct files has the same id" is
immediately invalid. The user cannot come into that situation then. And
anyway, when the user notices something, that's a discovery, not an
expectation.

>> The SHA-1 hash is created from the object, that means
>> the its type, size and data. It's not an id of a file in the working
>> tree, but of an object
>
> All true.  All somewhat subtle distinctions that are not nearly as  
> apparent unless you actually use the word "hash" as I have been  
> advocating.

Hu? How does saying "object hash" instead of "object id" make it any
more apparent that a file in the working tree is something else than a
git object?

>>> It's not a foregone conclusion that objects with the same value have
>>> identical ids, but it's immediately apparent if the id is known to  
>>> be a
>>> hash.
>>
>> You can't have two objects with the same contents to begin with, same
>> content => same object.
>
> In the Git world, I agree.  In general, I disagree.

I don't think were discussing a term to describe something that
identifies an object in general. So, "in general" you can disagree as
much as you want, but for git that doesn't matter at all.

> The fact that is so in the Git world is reinforced by the notion that
> the id of an object is a hash of its contents.
>
>> You can just have that one object stored multiple times in different
>> places (for sane implementations this  likely means that you have
>> more than one repo to look at, and each has its  own copy of that
>> object, but that's nothing you as an user should have to care about).
>
>> It's an identity relation: same name/id => same object. Unlike e.g. a
>> hash-table where you are expected to deal with collisions, and having
>> the same hash doesn't mean that you have identical data.  But that's
>> not true of git, it expects an identity relation, which is IMHO
>> better expressed through "object name" or "object id".
>
> Yes, that's true in the Git world (though not necessarily elsewhere), or 
> at least you hope it is.  In fact, there's no guarantee that SHA1  
> collisions won't occur; it's just exremely unlikely.  In fact, if you  
> google it you can find some interesting papers about SHA1 collision.

Sure, it's an assumption that has been made and is required to hold true
for git to work.

> Another way to express what you wrote above:
>
>    same same id => same hash ?=> same contents => same object
>
> where ?=> means "almost certainly implies."

No, that chain shows how git could be "unreliable" when you get hash
collisions. You could put that into a chapter that explains the
implications of the way git generates its object ids. But it's not very
interesting when you use git and (implicitly) trust the assumption that
no collisions happen.

For that case, you need a different chain:

same name/id ==> same object ==> same content

That's interesting when you e.g. want to "access" some object or when
you look at a tree that references the same object twice. For example
when both references are for file entries, you know that those files
have the same content. That it is a hash doesn't matter, the id could be
anything that uniquely identifies an object. The "same object ==> same
content" part should be pretty obvious, so you only need to know that
the "same name/id ==> same object" part is true, i.e. that the object
name/id uniquely identifies the object. And that _is_ true, simply
because you cannot have two objects in the same repo that have the same
hash and thus the same id. Even if you get a collision, you'll still
have just one object.  And that's not something that a term that
contains the word "hash" is telling me, it would instead tell me that it
is not something that really uniquely identifies an object, although git
uses it as such.


Only when you want to explain how git manages to avoid duplicated
storage of fully identical contents, then you need to mention that the
object names are the hashes of the full object contents. But that's not
what you actually use the object names for.

same content ==> same content hash ==> object name/id ==> same object

(Actually, you need an additional detail: "same
file/symlink/directory/... contents ==> same object contents", which
can't be made explicit by just saying that you use a hash).

Your chain was in the wrong order and explains neither the "a tree that
has the same object name/id for two entries" case (because of the
uncertainity of the "same hash ?=> same content" part), nor, when read
in the other direction, where all implications are true, why same
content leads to the same object (as it already starts at the object
level).

>> You can still say that the name/id is generated by using a hash
>> function, but the important part is that the name/id is used to
>> _uniquely_ identify an object,  which isn't apparent when you call it
>> a hash.
>
> I think the implication is important in both directions.  Neither one is 
> self-evident to a new user.  Maybe the right answer is 'hash id'.

git could work different. Just moving the storage of the filenames from
the tree objects to the blobs would mean that you'd get different
objects for files that have the same content but different names. You'd
still have a hash of the object contents as the object name, but
suddenly you get more objects. Just saying "hash" or "hash id" doesn't
magically explain all the other things.


Björn

  reply	other threads:[~2009-04-26 17:58 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 19:38 [doc] User Manual Suggestion David Abrahams
2009-04-23 17:57 ` J. Bruce Fields
2009-04-23 18:37   ` Michael Witten
2009-04-23 20:16     ` Jeff King
2009-04-23 20:45       ` Michael Witten
2009-04-23 21:31         ` David Abrahams
2009-04-24  0:31           ` Michael Witten
2009-04-24 14:18           ` Jeff King
2009-04-24 14:20             ` J. Bruce Fields
2009-04-24 17:28             ` David Abrahams
2009-04-24 18:15               ` Jeff King
2009-04-24 19:00                 ` David Abrahams
2009-04-24 20:24                   ` Jeff King
2009-04-24 21:06                     ` David Abrahams
2009-04-24 22:45                       ` Björn Steinbrink
2009-04-25  0:39                         ` David Abrahams
2009-04-26 23:35                           ` Björn Steinbrink
2009-04-24 14:11         ` Jeff King
2009-04-24 14:30           ` Michael Witten
2009-04-24 14:33             ` Michael Witten
2009-04-24 15:04             ` Jeff King
2009-04-24 15:18               ` Michael Witten
2009-04-24 17:38                 ` J. Bruce Fields
2009-04-24 18:27                   ` Jeff King
2009-04-24 18:35                     ` J. Bruce Fields
     [not found]                   ` <34BD51FF-0908-48A8-BBBC-E27B0EFB32E5@boostpro.com>
2009-04-24 18:52                     ` J. Bruce Fields
2009-04-25 10:35                       ` Felipe Contreras
2009-04-24 19:12                   ` Michael Witten
2009-04-23 21:26       ` David Abrahams
2009-04-23 22:51         ` Johan Herland
2009-04-24  0:30           ` Michael Witten
2009-04-24 20:30             ` Johan Herland
2009-04-24 21:34               ` Daniel Barkalow
2009-04-24 21:38                 ` Jeff King
2009-04-24 22:18                   ` Michael Witten
2009-04-24 22:25                     ` Michael Witten
2009-04-24 23:11                       ` Daniel Barkalow
2009-04-24 23:14                         ` Jeff King
2009-04-24 23:18                           ` Michael Witten
2009-04-24 23:31                           ` Michael Witten
2009-04-24 23:35                             ` Jeff King
2009-04-25  0:19                               ` Michael Witten
2009-04-25 10:18                           ` Felipe Contreras
2009-04-24 23:26                         ` Michael Witten
2009-04-25 18:55                           ` Daniel Barkalow
2009-04-25 19:16                             ` Michael Witten
2009-04-25 19:24                               ` Felipe Contreras
2009-04-25 19:36                                 ` David Abrahams
2009-04-25 20:53                                   ` Felipe Contreras
2009-04-26 11:28                                   ` Björn Steinbrink
2009-04-26 13:55                                     ` David Abrahams
2009-04-26 17:56                                       ` Björn Steinbrink [this message]
2009-04-26 20:17                                         ` David Abrahams
2009-04-26 22:25                                           ` Björn Steinbrink
2009-04-27  1:41                                             ` David Abrahams
2009-04-27 16:30                                             ` David Abrahams
2009-04-27 16:52                                               ` Michael Witten
2009-04-26 16:36                                     ` Michael Witten
2009-04-26 18:12                                       ` Björn Steinbrink
2009-04-26 20:20                                         ` David Abrahams
2009-04-25  0:41                         ` David Abrahams
2009-04-24 23:16                     ` Björn Steinbrink
2009-04-25  0:01                       ` Michael Witten
2009-04-25  0:48                         ` David Abrahams
2009-04-26 22:42                           ` Björn Steinbrink
2009-05-02 15:53                         ` Björn Steinbrink
2009-05-02 18:36                           ` Michael Witten
2009-05-02 21:11                             ` Björn Steinbrink
2009-05-02 23:13                               ` Michael Witten
2009-05-02 23:32                                 ` Björn Steinbrink
2009-05-03  1:10                                   ` Michael Witten
2009-05-03  1:48                                     ` Björn Steinbrink
2009-05-03  1:18                                 ` Mark Lodato
2009-05-03  1:26                                   ` Michael Witten
2009-04-24 23:21                   ` Daniel Barkalow
2009-04-24 23:25                     ` Jeff King
2009-04-26 23:41                       ` Björn Steinbrink
2009-04-24 23:29                     ` Michael Witten
2009-04-27  0:00                       ` Björn Steinbrink
2009-04-25  0:19                   ` David Abrahams
2009-04-25  0:26                     ` Michael Witten
2009-04-25  0:35                     ` Jeff King
2009-04-25  0:53                       ` David Abrahams
2009-04-29  6:34                         ` Jeff King
2009-04-29 13:27                           ` David Abrahams
2009-04-29 14:05                             ` Jeff King
2009-04-24  2:29     ` J. Bruce Fields
2009-04-24  2:34       ` Michael Witten
2009-04-24  4:06       ` David Abrahams
2009-04-24 14:10         ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090426175613.GA4942@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=bfields@fieldses.org \
    --cc=dave@boostpro.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johan@herland.net \
    --cc=mfwitten@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).