Re: [PATCH v2] dir: special case check for the possibility that pathspec is NULL
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Oct 1, 2019, 18:40 UTC
- Message-ID
- <20191001184049.GA30113@generichostname>
- In-Reply-To
- <20191001183005.16977-1-newren@gmail.com>
Hi Elijah,
On Tue, Oct 01, 2019 at 11:30:05AM -0700, Elijah Newren wrote:
[...]
Show 48 quoted lines
> 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 theProbably not worth a reroll but we're missing "gitweb directory" at the end of the comment. Other than that, it looks good to me.
Thanks again for the prompt fix,
Denton
Show 11 quoted lines
> + git add gitweb && > + git commit -m "add gitweb/subdir/file" && > + > + git checkout master > + ) > +' > + > test_done > -- > 2.23.0.25.g3f4444bfd7.dirty >