All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Alberto Bertogli <albertito@gmail.com>,
	git@vger.kernel.org, Johan Herland <johan@herland.net>
Subject: Re: [REVISED PATCH 2/6] Introduce commit notes
Date: Thu, 19 Jul 2007 02:34:00 -0700	[thread overview]
Message-ID: <7vodi83fg7.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vfy3l3rj0.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Wed, 18 Jul 2007 22:13:07 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Linus Torvalds <torvalds@linux-foundation.org> writes:
> ...
>> So if you're really really *really* unlucky, you might end up having to 
>> fall back on the linear search. But it still works!
>>
>> Can anybody see anything wrong in my thinking above?
> ...
> But the real problem of this approach of course is that this is
> not reliable and can get a false match.  You can find your
> beginning NUL in the SHA-1 part of one entry, and terminating
> NUL later in the SHA-1 part of next entry, and you will never
> notice.

In other words, if you are really really *really* unlucky, not
only you might end up being fooled by random byte sequences in
SHA-1 part of the tree object, you would not even notice that
you have to fall back on the linear search.

I've long time ago concluded that if we care about reliability
(and we do very much), a bisectable tree without breaking
backward compatibility is impossible.  I was hoping to find a
"hole" in tree object format so that I can place an extended
section that is invisible to older versions of git, and place a
table that records offsets of each tree entries to help
bisection and/or perhaps a hash table to help look-up, but I do
not think it is possible.  In the case of index file, the
original file format had a hole after the cache-entry array
where we can later squeeze an extension section that is
invisible to older versions of git.  But the tree object format
is designed so tight that I do not see there is any place to put
an extension section.

Side note: I also think adding "extension section" to tree
object is not a good idea to begin with.  The data nor length of
such a section cannot participate in hash computation to derive
the tree's object name so that we can still compare two tree
objects (with and without such extension) that have the same
contents by only looking at their object names.  But having
contents that are not counted as parts of the object's name goes
against the reliability and safety of git.

> ...
> I was suggesting to have a specialized parser only to read such
> tree objects that are "abused" to represent notes.  You can
> cheaply validate that these trees are of expected shape.
> ...
> For an added safety, a "notes" writer could even throw in
> signature bytes (say, a symlink whose name is " !" in the
> top-level tree, and another symlink " !{37}" in the second-level
> tree) to protect the reader.

Of course, even with the above trick with relatively cheap
validation based on size, entry format, and "signature entries",
the way I outlined to speed up "notes" access really relies on
the tree objects used in "notes" to be well formed.  If somebody
throws in a tree that is not really a "note" to refs/notes/, and
if I am really really *really* unlucky, not only I might end up
being fooled by random byte sequences in SHA-1 part of the tree
object, I would not even notice that I am reading garbage and
end up giving garbage as "note" to the object back to the user.

  reply	other threads:[~2007-07-19  9:34 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-15 23:19 [PATCH 0/6] Introduce commit notes Johannes Schindelin
2007-07-15 23:22 ` [PATCH 1/6] Rename git_one_line() to git_line_length() and export it Johannes Schindelin
2007-07-15 23:23 ` [PATCH 2/6] Introduce commit notes Johannes Schindelin
2007-07-15 23:36   ` Junio C Hamano
2007-07-15 23:52     ` Johannes Schindelin
2007-07-16  0:05     ` Junio C Hamano
2007-07-16  5:11   ` Junio C Hamano
2007-07-19  2:30     ` [REVISED PATCH " Johannes Schindelin
2007-07-19  3:28       ` Linus Torvalds
2007-07-19  5:13         ` Junio C Hamano
2007-07-19  9:34           ` Junio C Hamano [this message]
2007-07-19  9:57             ` Adam Hayek
2007-07-19 10:58             ` Andy Parkins
2007-07-19 11:10               ` Johannes Schindelin
2007-07-19 14:33                 ` Andy Parkins
2007-07-19 17:42             ` Linus Torvalds
2007-07-20  0:20               ` Junio C Hamano
2007-07-20  4:59             ` Shawn O. Pearce
2007-07-19 17:20           ` Linus Torvalds
2007-07-19  9:50         ` Johannes Schindelin
2007-07-19 10:34         ` Olivier Galibert
2007-07-19 17:50           ` Linus Torvalds
2007-07-19  9:05       ` Wincent Colaiuta
2007-07-19  9:24         ` Johannes Schindelin
2007-07-19  9:54       ` Sven Verdoolaege
2007-07-15 23:23 ` [PATCH 3/6] Add git-notes Johannes Schindelin
2007-07-16  5:11   ` Junio C Hamano
2007-07-19  2:31     ` [REVISED PATCH " Johannes Schindelin
2007-07-19  2:54       ` Johannes Schindelin
2007-07-15 23:24 ` [PATCH 4/6] Add a test script for "git notes" Johannes Schindelin
2007-07-16  5:11   ` Junio C Hamano
2007-07-19  2:32     ` [REVISED PATCH " Johannes Schindelin
2007-07-15 23:24 ` [PATCH 5/6] Document git-notes Johannes Schindelin
2007-07-15 23:26 ` [WIP PATCH 6/6] notes: add notes-index for a substantial speedup Johannes Schindelin
2007-07-15 23:33   ` Johannes Schindelin
2007-07-16  6:01   ` Shawn O. Pearce
2007-07-16 16:29     ` Johannes Schindelin
2007-07-16  7:57 ` [PATCH 0/6] Introduce commit notes Andy Parkins
2007-07-16  8:11   ` Junio C Hamano
2007-07-16 16:26     ` Johannes Schindelin
2007-07-16 17:56       ` Junio C Hamano
2007-07-19  1:34         ` Johannes Schindelin

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=7vodi83fg7.fsf@assigned-by-dhcp.cox.net \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=albertito@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johan@herland.net \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.