Re: [PATCH v2] dir: special case check for the possibility that pathspec is NULL
- From
Elijah Newren <newren@gmail.com>
- Date
- Oct 1, 2019, 18:54 UTC
- Message-ID
- <CABPp-BEmtnXT9+=+P4-D-0yKM075zstnaovL1P22vfn5FNdfMA@mail.gmail.com>
- In-Reply-To
- <20191001184049.GA30113@generichostname>
On Tue, Oct 1, 2019 at 11:41 AM Denton Liu <liu.denton@gmail.com> wrote:
Show 58 quoted lines
>
> Hi Elijah,
>
> On Tue, Oct 01, 2019 at 11:30:05AM -0700, Elijah Newren wrote:
>
> [...]
>
> > diff --git a/dir.c b/dir.c
> > index 7ff79170fc..bd39b86be4 100644
> > --- a/dir.c
> > +++ b/dir.c
> > @@ -1962,8 +1962,9 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
> > ((state == path_untracked) &&
> > (get_dtype(cdir.de, istate, path.buf, path.len) == DT_DIR) &&
> > ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
> > - do_match_pathspec(istate, pathspec, path.buf, path.len,
> > - baselen, NULL, DO_MATCH_LEADING_PATHSPEC) == MATCHED_RECURSIVELY_LEADING_PATHSPEC))) {
> > + (pathspec &&
> > + do_match_pathspec(istate, pathspec, path.buf, path.len,
> > + baselen, NULL, DO_MATCH_LEADING_PATHSPEC) == MATCHED_RECURSIVELY_LEADING_PATHSPEC)))) {
> > struct untracked_cache_dir *ud;
> > ud = lookup_untracked(dir->untracked, untracked,
> > path.buf + baselen,
> > @@ -1975,7 +1976,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
> > if (subdir_state > dir_state)
> > dir_state = subdir_state;
> >
> > - if (!match_pathspec(istate, pathspec, path.buf, path.len,
> > + if (pathspec &&
> > + !match_pathspec(istate, pathspec, path.buf, path.len,
> > 0 /* prefix */, NULL,
> > 0 /* do NOT special case dirs */))
> > state = path_none;
> > diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
> > index 192c94eccd..a840919967 100755
> > --- a/t/t0050-filesystem.sh
> > +++ b/t/t0050-filesystem.sh
> > @@ -131,4 +131,25 @@ $test_unicode 'merge (silent unicode normalization)' '
> > git merge topic
> > '
> >
> > +test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' '
> > + git init repo &&
> > + (
> > + cd repo &&
> > +
> > + >Gitweb &&
> > + git add Gitweb &&
> > + git commit -m "add Gitweb" &&
> > +
> > + git checkout --orphan todo &&
> > + git reset --hard &&
> > + mkdir -p gitweb/subdir &&
> > + >gitweb/subdir/file &&
> > + # it is not strictly necessary to add and commit the
>
> Probably not worth a reroll but we're missing "gitweb directory" at the
> end of the comment. Other than that, it looks good to me.Yuck, I accidentally only removed half the comment when I intended to remove it all? Whoops. I think it's worth a reroll; it's just a single patch. I'll send it out.