Re: [PATCH v2 5/8] sparse-checkout: create helper methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/2021 3:50 PM, Derrick Stolee via GitGitGadget wrote:
...
> +enum pattern_match_result path_in_sparse_checkout(const char *path,
> +						  struct index_state *istate)
> +{
> +	int dtype = DT_REG;
> +	init_sparse_checkout_patterns(istate);
> +
> +	if (!istate->sparse_checkout_patterns)
> +		return MATCHED;
> +
> +	return path_matches_pattern_list(path, strlen(path), NULL, &dtype,
> +					 istate->sparse_checkout_patterns,
> +					 istate);

While expanding on this work to fix behavior in 'git (add|rm|mv)' around
sparse entries, I noticed a problem with this method, specifically with
non-cone-mode patterns:

1. The NULL here should be the "basename" of the path, not NULL. This doesn't
   matter for cone mode, but _does_ matter for more general patterns.

2. The return type here can be UNDECIDED with general patterns, which really
   means "not matched" but is distinct from NOT_MATCHED because of the recursive
   assumptions when a directory is returned with NOT_MATCHED. Since the usage
   pattern for path_in_sparse_checkout() is to get a boolean result, the
   return type should switch to 'int' and we should return
   "path_matches_pattern_list(...) > 0".

I'm still doing some more testing to ensure I've got the necessary tweaks in
place to work with the other changes I'm going for. Plan on me sending a v3
with the appropriate changes here.

>  	/*
>  	 * Is the current path outside of the sparse cone?
>  	 * Then check if the region can be replaced by a sparse
>  	 * directory entry (everything is sparse and merged).
>  	 */
> -	match = path_matches_pattern_list(ct_path, ct_pathlen,
> -					  NULL, &dtype, pl, istate);
> +	match = path_in_sparse_checkout(ct_path, istate);
>  	if (match != NOT_MATCHED)
>  		can_convert = 0;

We could remove the use of "match" here and use the boolean result of
path_in_sparse_checkout() instead.

Thanks,
-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux