Re: [PATCH 4/4] attr.c: fix matching "subdir" without the trailing slash
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 25, 2013, 07:20 UTC
- Message-ID
- <CACsJy8CNjKP1y925mb8_t_hs0QCZwaY6mYTe6EMvbJk2pPifew@mail.gmail.com>
- In-Reply-To
- <1364191510-8900-5-git-send-email-pclouds@gmail.com>
On Mon, Mar 25, 2013 at 1:05 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 16 quoted lines
> The story goes back to 94bc671 (Add directory pattern matching to > attributes - 2012-12-08). Before this commit, directories are passed > to path_matches without the trailing slash. This is fine for matching > pattern "subdir" with "foo/subdir". > > Patterns like "subdir/" (i.e. match _directory_ subdir) won't work > though. So paths are now passed to path_matches with the trailing > slash (i.e. "subdir/"). The trailing slash is used as the directory > indicator (similar to dtype in exclude case). This makes pattern > "subdir/" match directory "subdir/". Pattern "subdir" no longer match > subdir, which is now "subdir/". > > As the trailing slash in pathname is the directory indicator, we do > not need to keep it in the pathname for matching. The trailing slash > should be turned to dtype "DT_DIR" and stripped out of pathname. This > keeps the code pattern similar to exclude.
On second thought, maybe we should not pass path "subdir/" at all. Instead we create a fake dtype based on the trailing slash and pass it down to attr.c:fill() -> path_matches(), just like how last_exclude_matching_from_list() is called.
-- Duy