From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2] index-format.txt: be more liberal on what can represent invalid cache tree
Date: Thu, 13 Dec 2012 08:14:47 +0700 [thread overview]
Message-ID: <1355361287-10875-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <7v4njr5eac.fsf@alter.siamese.dyndns.org>
We have been writing -1 as "invalid" since day 1. On that same day we
accept all negative entry counts as "invalid". So in theory all C Git
versions out there would be happy to accept any negative numbers. JGit
seems to do exactly the same.
Correct the document to reflect the fact that -1 is not the only magic
number. At least one implementation, libgit2, is found to treat -1
this way.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
On Thu, Dec 13, 2012 at 1:14 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> We have been writing -1 as "invalid" since day 1. On that same day we
>> accept all negative entry counts as "invalid". So in theory all C Git
>> versions out there would be happy to accept any negative numbers. JGit
>> seems to do exactly the same.
>
> I am of two minds here.
>
> The existing code is being more lenient than specified when they
> read stuff others wrote, but it still adheres to -1 when writing.
> Allowing random implementations to write random negative values will
> close the door for us to later update the specification to encode
> more informatin about these invalid entries by using negative value
> other than -1 here.
How would that work with existing versions? If you write -2 in
cache-tree, the next time 1.8.0 updates cache tree it writes -1 back.
That loses whatever information you attach to -2. A new cache-tree
extension is probably better.
> I am OK with a reword to say "negative means invalid, and writers
> should write -1 for invalid entries", but without the latter half,
> this change is not justified.
Done.
Documentation/technical/index-format.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/technical/index-format.txt b/Documentation/technical/index-format.txt
index 9d25b30..ce28a7a 100644
--- a/Documentation/technical/index-format.txt
+++ b/Documentation/technical/index-format.txt
@@ -161,8 +161,9 @@ GIT index format
this span of index as a tree.
An entry can be in an invalidated state and is represented by having
- -1 in the entry_count field. In this case, there is no object name
- and the next entry starts immediately after the newline.
+ a negative number in the entry_count field. In this case, there is no
+ object name and the next entry starts immediately after the newline.
+ When writing an invalid entry, -1 should always be used as entry_count.
The entries are written out in the top-down, depth-first order. The
first entry represents the root level of the repository, followed by the
--
1.8.0.rc2.23.g1fb49df
next prev parent reply other threads:[~2012-12-13 1:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-12 12:44 [PATCH] index-format.txt: be more liberal on what can represent invalid cache tree Nguyễn Thái Ngọc Duy
2012-12-12 18:14 ` Junio C Hamano
2012-12-13 1:14 ` Nguyễn Thái Ngọc Duy [this message]
2012-12-13 1:55 ` [PATCH v2] " Junio C Hamano
2012-12-13 18:11 ` Junio C Hamano
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=1355361287-10875-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).