git.vger.kernel.org archive mirror
 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, Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 1/3] traverse_trees(): allow pruning with pathspec
Date: Tue, 30 Aug 2011 19:53:15 +0700	[thread overview]
Message-ID: <CACsJy8CmZv7Fuhw+m6X2CVO4vWLYFQNmStu1jJmhVXSi4mPxJQ@mail.gmail.com> (raw)
In-Reply-To: <1314653603-7533-2-git-send-email-gitster@pobox.com>

On Tue, Aug 30, 2011 at 4:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
> @@ -316,10 +328,18 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)

Not related to the patch, but a bit of comment how this function works
and how it expects info->fn() to return would be appreciated.


>        struct name_entry *entry = xmalloc(n*sizeof(*entry));
>        int i;
>        struct tree_desc_x *tx = xcalloc(n, sizeof(*tx));
> +       struct strbuf base = STRBUF_INIT;
> +       int interesting = 1;

I suspect making "base" an argument to traverse_trees() may save us a
few more alloc/free (or a lot, depends on how crowded the tree is).
There are only two users of traverse_trees(): merge-tree.c and
unpack-trees.c, changes should be manageable.


> @@ -376,16 +396,22 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
>                        mask |= 1ul << i;
>                        if (S_ISDIR(entry[i].mode))
>                                dirmask |= 1ul << i;
> +                       e = &entry[i];
>                }

Why? "e" is not used in that loop or anywhere after that.


>                if (!mask)
>                        break;
> -               ret = info->fn(n, mask, dirmask, entry, info);
> -               if (ret < 0) {
> -                       error = ret;
> -                       if (!info->show_all_errors)
> -                               break;
> +               interesting = prune_traversal(e, info, &base, interesting);
> +               if (interesting < 0)
> +                       break;

I don't really understand this function to comment. But I guess when
interesting < 0, we only skip info->fn() and assume it returns "mask"
(its user unpack_callback() only returns either "mask" or -1). So the
code at the end of the main loop

		for (i = 0; i < n; i++)
			if (mask & (1ul << i))
				update_extended_entry(tx + i, entry + i);

should not be skipped (by putting a break here). IOW, there should be
no "break;" here.


>                }
> -               mask &= ret;
>                ret = 0;

While at there, remove "ret = 0;" too? I think this statement is useless.
-- 
Duy

  reply	other threads:[~2011-08-30 12:53 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23  7:25 What's the difference between `git show branch:file | diff -u - file` vs `git diff branch file`? Marat Radchenko
2011-08-23 10:03 ` Michael J Gruber
2011-08-23 10:52   ` Marat Radchenko
2011-08-23 15:20     ` Michael Witten
2011-08-23 15:34     ` Michael J Gruber
2011-08-23 16:45       ` Marat Radchenko
2011-08-23 17:15       ` Junio C Hamano
2011-08-23 18:21         ` Marat Radchenko
2011-08-23 20:07         ` Michael J Gruber
2011-08-25 16:09           ` Marat Radchenko
2011-08-25 21:10           ` Junio C Hamano
2011-08-26  9:43             ` Marat Radchenko
2011-08-29  7:41 ` Nguyen Thai Ngoc Duy
2011-08-29 14:48   ` Marat Radchenko
2011-08-29 16:09     ` Nguyen Thai Ngoc Duy
2011-08-29 17:18       ` Junio C Hamano
2011-08-29 20:42         ` Junio C Hamano
2011-08-29 20:50           ` Junio C Hamano
2011-08-29 21:09           ` Junio C Hamano
2011-08-29 21:33           ` [PATCH 0/3] Un-pessimize "diff-index $commit -- $pathspec" Junio C Hamano
2011-08-29 21:33             ` [PATCH 1/3] traverse_trees(): allow pruning with pathspec Junio C Hamano
2011-08-30 12:53               ` Nguyen Thai Ngoc Duy [this message]
2011-08-30 17:44                 ` Junio C Hamano
2011-08-31  1:35                   ` Nguyen Thai Ngoc Duy
2011-10-09 15:39               ` Michael Haggerty
2011-10-09 21:35                 ` Nguyen Thai Ngoc Duy
2011-10-10  4:42                   ` Michael Haggerty
2011-08-29 21:33             ` [PATCH 2/3] unpack-trees: " Junio C Hamano
2011-08-30 13:03               ` Nguyen Thai Ngoc Duy
2011-08-30 17:32                 ` Junio C Hamano
2011-08-30 15:24               ` David Michael Barr
2011-08-29 21:33             ` [PATCH 3/3] diff-index: pass pathspec down to unpack-trees machinery Junio C Hamano
2012-01-11  6:31               ` Jonathan Nieder
2012-01-11  8:05                 ` Junio C Hamano
2012-01-11 12:33                 ` Nguyen Thai Ngoc Duy
2012-01-11 12:47                   ` Nguyen Thai Ngoc Duy
2012-01-11 20:40                   ` Junio C Hamano
2012-01-12  4:09                 ` [PATCH] tree_entry_interesting: make recursive mode default Nguyễn Thái Ngọc Duy
2012-01-12  5:04                   ` Junio C Hamano
2012-01-12  5:44                     ` Nguyen Thai Ngoc Duy
2012-01-14  9:23                   ` [PATCH v2 1/2] Document limited recursion pathspec matching with wildcards Nguyễn Thái Ngọc Duy
2012-01-14  9:23                     ` [PATCH v2 2/2] tree_entry_interesting: make recursive mode default Nguyễn Thái Ngọc Duy
2012-01-15  3:12                       ` Junio C Hamano
2012-01-15 10:03                         ` Nguyen Thai Ngoc Duy
2012-01-16 22:15                           ` Junio C Hamano
2012-01-18  8:59                             ` Nguyen Thai Ngoc Duy
2012-01-15  2:38                     ` [PATCH v2 1/2] Document limited recursion pathspec matching with wildcards Junio C Hamano
2012-01-15  9:48                       ` Nguyen Thai Ngoc Duy
2011-08-29 21:56             ` [PATCH 0/3] Un-pessimize "diff-index $commit -- $pathspec" Linus Torvalds
2011-08-29 22:05               ` Junio C Hamano
2011-08-29 22:11                 ` Linus Torvalds
2011-08-29 23:42                   ` Junio C Hamano
2011-08-30  6:16                     ` Marat Radchenko
2011-08-31  0:18                       ` Junio C Hamano
2011-08-30 10:04             ` Michael J Gruber
2011-08-30 17:03               ` 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=CACsJy8CmZv7Fuhw+m6X2CVO4vWLYFQNmStu1jJmhVXSi4mPxJQ@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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 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).