From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org,
Ilari Liusvaara <ilari.liusvaara@elisanet.fi>,
Jakub Narebski <jnareb@gmail.com>,
"Dmitry S. Kravtsov" <idkravitz@gmail.com>,
Shawn Pearce <spearce@spearce.org>
Subject: Re: [PATCH] cache-tree: do not cache empty trees
Date: Mon, 7 Feb 2011 16:57:13 +0700 [thread overview]
Message-ID: <20110207095713.GA19653@do> (raw)
In-Reply-To: <20110207091740.GA5391@elie>
On Mon, Feb 07, 2011 at 03:17:40AM -0600, Jonathan Nieder wrote:
> While this violates some seeming invariants, like
>
> 1.
> git reset --hard
> git commit --allow-empty
> git rev-parse HEAD^^{tree} >expect
> git rev-parse HEAD^{tree} >actual
> test_cmp expect actual
>
> 2.
> git reset --hard
> git revert HEAD
> if git rev-parse HEAD~2
> then
> git rev-parse HEAD~2^{tree} >expect
> git rev-parse HEAD^{tree} >actual
> test_cmp expect actual
> fi
>
> , I think it's a good change. Malformed modes in trees already break
> those false invariants iiuc.
Perhaps it's not a good approach after all. What I wanted was to make
pre-1.8.0 tolerate empty trees created by 1.8.0. Perhaps it's better
to just let pre-1.8.0 refuse to work with empty trees, forcing users
to upgrade to 1.8.0?
The (untested) patch below would make git refuse to create an index
from a tree that contains empty trees. Hmm?
diff --git a/cache-tree.c b/cache-tree.c
index f755590..e33998a 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -619,6 +619,8 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
else {
struct cache_tree_sub *sub;
struct tree *subtree = lookup_tree(entry.sha1);
+ if (!hashcmp(entry.sha1, EMPTY_TREE_SHA1_BIN))
+ die("empty tree .../%s detected!", entry.path);
if (!subtree->object.parsed)
parse_tree(subtree);
sub = cache_tree_sub(it, entry.path);
diff --git a/unpack-trees.c b/unpack-trees.c
index 1ca41b1..0e6738e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -434,6 +434,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long
void *buf[MAX_UNPACK_TREES];
struct traverse_info newinfo;
struct name_entry *p;
+ struct unpack_trees_options *o = info->data;
p = names;
while (!p->mode)
@@ -447,8 +448,11 @@ static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long
for (i = 0; i < n; i++, dirmask >>= 1) {
const unsigned char *sha1 = NULL;
- if (dirmask & 1)
+ if (dirmask & 1) {
sha1 = names[i].sha1;
+ if (o->merge && !hashcmp(sha1, EMPTY_TREE_SHA1_BIN))
+ return error("empty tree .../%s detected!", p->path);
+ }
buf[i] = fill_tree_descriptor(t+i, sha1);
}
--
Duy
next prev parent reply other threads:[~2011-02-07 9:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-05 8:30 [PATCH] cache-tree: do not cache empty trees Nguyễn Thái Ngọc Duy
2011-02-05 9:50 ` Nguyễn Thái Ngọc Duy
2011-02-05 10:14 ` Jonathan Nieder
2011-02-05 10:32 ` Nguyen Thai Ngoc Duy
2011-02-05 14:07 ` Nguyễn Thái Ngọc Duy
2011-02-07 2:09 ` Junio C Hamano
2011-02-07 2:36 ` Nguyen Thai Ngoc Duy
2011-02-07 8:17 ` [PATCH] correct type of EMPTY_TREE_SHA1_BIN Jonathan Nieder
2011-02-09 23:33 ` Junio C Hamano
2011-02-07 9:17 ` [PATCH] cache-tree: do not cache empty trees Jonathan Nieder
2011-02-07 9:57 ` Nguyen Thai Ngoc Duy [this message]
2011-02-07 12:18 ` Ilari Liusvaara
2011-02-07 12:29 ` Nguyen Thai Ngoc Duy
2011-02-07 12:32 ` Jonathan Nieder
2011-02-07 20:48 ` Junio C Hamano
2011-02-08 4:11 ` Nguyen Thai Ngoc Duy
2011-02-08 4:30 ` Jonathan Nieder
2011-02-15 10:19 ` Yann Dirson
2011-02-16 14:29 ` Jakub Narebski
2011-02-08 10:40 ` Ilari Liusvaara
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=20110207095713.GA19653@do \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=idkravitz@gmail.com \
--cc=ilari.liusvaara@elisanet.fi \
--cc=jnareb@gmail.com \
--cc=jrnieder@gmail.com \
--cc=spearce@spearce.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.