From: Elijah Newren <newren@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 02/16] list-objects: limit traversing within the given subtree if core.subtree is set
Date: Sun, 1 Aug 2010 22:21:17 -0600 [thread overview]
Message-ID: <AANLkTikZrD+RRMnae0OOPU_keuu97LditFZnekcpkrYZ@mail.gmail.com> (raw)
In-Reply-To: <1280593105-22015-3-git-send-email-pclouds@gmail.com>
Hi,
2010/7/31 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> list-objects.c | 23 +++++++++++++++++------
> 1 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/list-objects.c b/list-objects.c
> index 8953548..1b25b54 100644
> --- a/list-objects.c
> +++ b/list-objects.c
> @@ -61,12 +61,15 @@ static void process_tree(struct rev_info *revs,
> struct tree *tree,
> show_object_fn show,
> struct name_path *path,
> - const char *name)
> + const char *name,
> + const char *subtree)
> {
> struct object *obj = &tree->object;
> struct tree_desc desc;
> struct name_entry entry;
> struct name_path me;
> + const char *slash;
> + int subtree_len;
Perhaps slash should be initialized to NULL? Otherwise I think it
will be used uninitialized.
>
> if (!revs->tree_objects)
> return;
> @@ -82,13 +85,21 @@ static void process_tree(struct rev_info *revs,
> me.elem = name;
> me.elem_len = strlen(name);
>
> + if (subtree) {
> + slash = strchr(subtree, '/');
> + subtree_len = slash ? slash - subtree : strlen(subtree);
> + }
> +
> init_tree_desc(&desc, tree->buffer, tree->size);
>
> while (tree_entry(&desc, &entry)) {
> - if (S_ISDIR(entry.mode))
> - process_tree(revs,
> - lookup_tree(entry.sha1),
> - show, &me, entry.path);
> + if (S_ISDIR(entry.mode)) {
> + if (!subtree || !strncmp(entry.path, subtree, subtree_len))
Only one subdirectory allowed? What if someone wants a sparse clone
containing two or more directories? (Actually, that's not so much of
a "what if" -- it's exactly what I want in about half my usecases for
sparse clones.)
> + process_tree(revs,
> + lookup_tree(entry.sha1),
> + show, &me, entry.path,
> + slash && slash[1] ? slash+1 : NULL);
If I read correctly, slash will be used uninitialized here whenever
subtree == NULL.
next prev parent reply other threads:[~2010-08-02 4:21 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-31 16:18 [PATCH 00/16] Subtree clone proof of concept Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 01/16] Add core.subtree Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 02/16] list-objects: limit traversing within the given subtree if core.subtree is set Nguyễn Thái Ngọc Duy
2010-08-01 11:30 ` Ævar Arnfjörð Bjarmason
2010-08-01 23:11 ` Nguyen Thai Ngoc Duy
2010-08-02 4:21 ` Elijah Newren [this message]
2010-08-02 6:51 ` Nguyen Thai Ngoc Duy
2010-07-31 16:18 ` [PATCH 03/16] parse_object: keep sha1 even when parsing replaced one Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 04/16] Allow to invalidate a commit in in-memory object store Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 05/16] Hook up replace-object to allow bulk commit replacement Nguyễn Thái Ngọc Duy
2010-08-02 19:58 ` Junio C Hamano
2010-08-02 22:42 ` Nguyen Thai Ngoc Duy
2010-07-31 16:18 ` [PATCH 06/16] upload-pack: use a separate variable to control whether internal rev-list is used Nguyễn Thái Ngọc Duy
2010-08-02 4:25 ` Elijah Newren
2010-07-31 16:18 ` [PATCH 07/16] upload-pack: support subtree pack Nguyễn Thái Ngọc Duy
2010-08-02 4:27 ` Elijah Newren
2010-07-31 16:18 ` [PATCH 08/16] fetch-pack: support --subtree Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 09/16] subtree: rewrite incoming commits Nguyễn Thái Ngọc Duy
2010-08-02 4:37 ` Elijah Newren
2010-07-31 16:18 ` [PATCH 10/16] clone: support subtree clone with parameter --subtree Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 11/16] pack-objects: add --subtree (for pushing) Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 12/16] subtree: rewriting outgoing commits Nguyễn Thái Ngọc Duy
2010-08-02 4:40 ` Elijah Newren
2010-07-31 16:18 ` [PATCH 13/16] Update commit_tree() interface to take base tree too Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 14/16] commit_tree(): rewriting/replacing new commits Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 15/16] commit: rewrite outgoing commits Nguyễn Thái Ngọc Duy
2010-07-31 16:18 ` [PATCH 16/16] do not use thin packs and subtree together (just a bad feeling about this) Nguyễn Thái Ngọc Duy
2010-08-01 4:14 ` [PATCH 00/16] Subtree clone proof of concept Sverre Rabbelier
2010-08-01 6:58 ` Nguyen Thai Ngoc Duy
2010-08-01 20:05 ` Sverre Rabbelier
2010-08-02 5:18 ` Elijah Newren
2010-08-02 7:10 ` Nguyen Thai Ngoc Duy
2010-08-02 22:55 ` Nguyen Thai Ngoc Duy
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=AANLkTikZrD+RRMnae0OOPU_keuu97LditFZnekcpkrYZ@mail.gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.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).