All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
	Ilari Liusvaara <ilari.liusvaara@elisanet.fi>,
	Jakub Narebski <jnareb@gmail.com>,
	Jonathan Nieder <jrnieder@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 09:36:37 +0700	[thread overview]
Message-ID: <AANLkTinCyOq4rmb-tf4B91bK97GWca-4DyC715tUv+zx@mail.gmail.com> (raw)
In-Reply-To: <7v62swwq7s.fsf@alter.siamese.dyndns.org>

2011/2/7 Junio C Hamano <gitster@pobox.com>:
>> diff --git a/cache-tree.c b/cache-tree.c
>> index f755590..03732ad 100644
>> --- a/cache-tree.c
>> +++ b/cache-tree.c
>> @@ -621,9 +621,18 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
>>                       struct tree *subtree = lookup_tree(entry.sha1);
>>                       if (!subtree->object.parsed)
>>                               parse_tree(subtree);
>> +                     if (!hashcmp(entry.sha1, (unsigned char *)EMPTY_TREE_SHA1_BIN)) {
>> +                             warning("empty tree detected! Will be removed in new commits");
>> +                             cnt = -1;
>> +                             break;
>> +                     }
>
> You shouldn't need the cast (if you did, then hashcmp() macro should be
> fixed so that you don't need to).

Or perhaps EMPTY_TREE_SHA1_BIN should be casted to const unsigned char
*. That would eliminate 4 typecastings elsewhere.

> I don't think warning() is warranted for an operation you introduced to
> keep the internal data structure consistent.

Worse. I don't think users know an empty tree is added or removed.
diff-tree does not show it (or should not, I haven't tested).

> Should this comparison done after we parsed the subtree, or should we be
> doing that before it?
>
> If you are adding this new check to a point where we have already parsed
> the subtree object, don't you have a better and cheaper way to detect if
> the subtree is empty than the 20-byte comparision, namely, perhaps by
> looking at subtree->size?

OK before is better.
-- 
Duy

  reply	other threads:[~2011-02-07  2:37 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 [this message]
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
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=AANLkTinCyOq4rmb-tf4B91bK97GWca-4DyC715tUv+zx@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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.