From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/WIP 02/11] notes-merge: use opendir/readdir instead of using read_directory()
Date: Thu, 27 Oct 2011 18:51:38 +1100 [thread overview]
Message-ID: <CACsJy8C4iHffr4UYP9SvCU0OPC-LocUORwAQ492LqaV_tyvFQA@mail.gmail.com> (raw)
In-Reply-To: <7vmxcn3b8w.fsf@alter.siamese.dyndns.org>
On Thu, Oct 27, 2011 at 4:37 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
>> Current read_directory() treats given path separately from contents
>> inside the path. If the given path has ".git", it's ok (but it'll stop
>> at .git if during tree recursion). The new read_directory() does not
>> make this exception, so when note-merge call
>> read_directory(".git/NOTES_MERGE_WORKTREE"), read_directory() sees
>> ".git" and stops immediately, assuming it's a gitlink.
>
> When read_directory("where/ever") is called, what kind of paths does it
> collect? Do the paths the function collects share "where/ever" as their
> common prefix? I thought it collects the paths relative to whatever
> top-level directory given to the function, so that "where/ever" could be
> anything.
Correct. But read_directory() takes pathspec now so naturally it does
not treat "where/ever" a common prefix anymore. So it has to open(".")
and starts from there. Even current code does not trust "where/ever"
completely. treat_leading_path() may dismiss "where/ever" if it's
excluded by .gitignore.
> Why does it even have to look at the given path in the first place and
> make a decision heavier than "can I opendir() and read from it"?
Because opendir("wh*/*r") may fail.
> In other
> words, if you see read_directory("some/thing/.git/more/stuff") and find a
> substring ".git/" in there, what "magic" gitlink handling does the code
> have to do?
"some/thing/.git" can be considered a new entry in index, so it should
stop traversing at ".git". But because "some/thing/.git" does not
exacly match "some/thing/.git/more/stuff", it is filtered out.
git-add deals with this case especially in order to avoid accidentally
replace "some/thing/.git" in index with "some/thing/.git/more/stuff".
But I feel it should be handled by read_directory(), not git-add.
> I do not think it matters for _this_ particular case, but I can for
> example imagine an alternative implementation of a merge that uses
> temporary working tree somewhere other than the main working tree, and one
> of the natural "temporary" places such a feature in the future may want to
> use is inside .git/ somewhere. If you are planning to close the door by
> breaking the behaviour of read_directory(".git/some_where") for such
> callers with this series, we need to be aware of it, and that is why I am
> not satisfied by your explanation.
Maybe I should step back a bit. Instead of treating any input to
read_directory() as pathspec, callers may provide two sets: a prefix
set and a pathspec set. read_directory() starts from the prefix set
without any checks, then descends in using pathspec.
But then what about the "if (treat_one_path(..) == path_ignored)" in
treat_leading_path()? Remove it?
--
Duy
next prev parent reply other threads:[~2011-10-27 7:52 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 6:36 [PATCH/WIP 00/11] read_directory() rewrite to support struct pathspec Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 01/11] Introduce "check-attr --excluded" as a replacement for "add --ignore-missing" Nguyễn Thái Ngọc Duy
2011-10-27 18:08 ` Junio C Hamano
2011-10-28 20:51 ` Nguyen Thai Ngoc Duy
2011-10-24 6:36 ` [PATCH/WIP 02/11] notes-merge: use opendir/readdir instead of using read_directory() Nguyễn Thái Ngọc Duy
2011-10-25 19:27 ` Junio C Hamano
2011-10-26 0:08 ` Nguyen Thai Ngoc Duy
2011-10-26 17:37 ` Junio C Hamano
2011-10-27 7:51 ` Nguyen Thai Ngoc Duy [this message]
2011-10-27 17:23 ` Junio C Hamano
2011-10-28 20:47 ` Nguyen Thai Ngoc Duy
2012-03-12 14:47 ` [PATCH 1/2] t3310: Add testcase demonstrating failure to --commit from within another dir Johan Herland
2012-03-12 14:47 ` [PATCH 2/2] notes-merge: use opendir/readdir instead of using read_directory() Johan Herland
2012-03-12 14:53 ` Nguyen Thai Ngoc Duy
2012-03-14 8:39 ` [PATCH jh/notes-merge-in-git-dir-worktree] fixup! t3310 on Windows Johannes Sixt
2012-03-14 11:39 ` Johan Herland
2012-03-14 11:59 ` Johannes Sixt
2012-03-14 12:20 ` David Bremner
2012-03-14 12:56 ` Johan Herland
2012-03-14 17:44 ` Junio C Hamano
2012-03-14 23:55 ` [PATCH 3/2] notes-merge: Don't remove .git/NOTES_MERGE_WORKTREE; it may be the user's cwd Johan Herland
2012-03-15 7:02 ` Junio C Hamano
2012-03-15 7:16 ` Junio C Hamano
2012-03-15 7:39 ` Johan Herland
2012-03-15 8:04 ` Re* " Junio C Hamano
2012-03-15 8:12 ` Junio C Hamano
2012-03-15 8:12 ` Johannes Sixt
2011-10-24 6:36 ` [PATCH/WIP 03/11] t5403: avoid doing "git add foo/bar" where foo/.git exists Nguyễn Thái Ngọc Duy
2011-10-25 19:19 ` Junio C Hamano
2011-10-26 0:18 ` Nguyen Thai Ngoc Duy
2011-10-26 17:26 ` Junio C Hamano
2011-10-27 8:06 ` Nguyen Thai Ngoc Duy
2011-10-27 17:41 ` Junio C Hamano
2011-10-30 5:55 ` Nguyen Thai Ngoc Duy
2011-10-30 7:08 ` Junio C Hamano
2011-10-30 9:55 ` Nguyen Thai Ngoc Duy
2011-10-30 23:47 ` Junio C Hamano
2011-10-24 6:36 ` [PATCH/WIP 04/11] tree-walk.c: do not leak internal structure in tree_entry_len() Nguyễn Thái Ngọc Duy
2011-10-25 19:20 ` Junio C Hamano
2011-10-24 6:36 ` [PATCH/WIP 05/11] symbolize return values of tree_entry_interesting() Nguyễn Thái Ngọc Duy
2011-10-25 19:24 ` Junio C Hamano
2011-10-27 18:36 ` Junio C Hamano
2011-10-30 9:17 ` Nguyen Thai Ngoc Duy
2011-10-24 6:36 ` [PATCH/WIP 06/11] read_directory_recursive: reduce one indentation level Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 07/11] tree_entry_interesting: make use of local pointer "item" Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 08/11] tree-walk: mark useful pathspecs Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 09/11] tree_entry_interesting: differentiate partial vs full match Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 10/11] read-dir: stop using path_simplify code in favor of tree_entry_interesting() Nguyễn Thái Ngọc Duy
2011-10-24 6:36 ` [PATCH/WIP 11/11] dir.c: remove dead code after read_directory() rewrite Nguyễn Thái Ngọc Duy
2011-10-24 17:10 ` [PATCH/WIP 00/11] read_directory() rewrite to support struct pathspec 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=CACsJy8C4iHffr4UYP9SvCU0OPC-LocUORwAQ492LqaV_tyvFQA@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).