public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Duy Nguyen <pclouds@gmail•com>
Cc: Git Mailing List <git@vger•kernel.org>, Peter Wu <peter@lekensteyn•nl>
Subject: Re: [PATCH v2] archive: support filtering paths with glob
Date: Tue, 23 Sep 2014 09:57:35 -0700	[thread overview]
Message-ID: <xmqqfvfijmv4.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACsJy8CwwzOuiL1GMcK9OWZSdSqCpLzVJPyNkHocH10_1VmXSA@mail.gmail.com> (Duy Nguyen's message of "Tue, 23 Sep 2014 06:04:31 +0700")

Duy Nguyen <pclouds@gmail•com> writes:

> On Tue, Sep 23, 2014 at 2:15 AM, Junio C Hamano <gitster@pobox•com> wrote:
>> When we have a/b/c and a/d/e to be written, the first round would
>> write a/ and then a/b/ with the above, and presumably elsewhere
>> somebody will write a/b/c; next time around we do need to write a/d/
>> but we wouldn't want to write a/ itself.  How is this code
>> preventing the recursion going all the way up every time to avoid
>> repeating a/?
>>
>> Puzzled...
>
> We never traverse 'a' (or any directory) twice and we only push a
> directory to the stack when we examine it. After a/b and a are written
> down and we examine 'd', 'a/d' is pushed to the stack. When we hit
> 'a/d/e', we only have 'a/d' in the stack, not 'a'.

So the traverser will feed you

	a/
        a/b/
        a/b/c
        a/d/
        a/d/e

in that order, and you keep a/ and a/b/ until you see a/b/c at which
time you flush the two queued ones and likewise for a/d/ and a/d/e.
When you queue a/d/ you do not decompose that to a/ and a/d/ because
you know that the caller of the callback would have made sure all
the leading path components have been given you by the time it gave
you a/d/, and it all works out fine.

Thanks for clarifying.

      reply	other threads:[~2014-09-23 16:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 22:17 git archive and glob pathspecs Peter Wu
2014-09-03  6:21 ` Duy Nguyen
2014-09-13 10:36   ` Peter Wu
2014-09-04 13:37 ` [PATCH] archive: support filtering paths with glob Nguyễn Thái Ngọc Duy
2014-09-13 10:52   ` Peter Wu
2014-09-21  3:55     ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2014-09-22 19:15       ` Junio C Hamano
2014-09-22 23:04         ` Duy Nguyen
2014-09-23 16:57           ` Junio C Hamano [this message]

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=xmqqfvfijmv4.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=pclouds@gmail$(echo .)com \
    --cc=peter@lekensteyn$(echo .)nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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