On 05/06/18 16:43, Nguyễn Thái Ngọc Duy wrote:
> This function mark_new_skip_worktree() has an argument named the_index
> which is also the name of a global variable. While they have different
> types (the global the_index is not a pointer) mistakes can easily
> happen and it's also confusing for readers. Rename the function
> argument to something other than the_index.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
> ---
> unpack-trees.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 5d06aa9c98..60d1138e08 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1231,7 +1231,7 @@ static int clear_ce_flags(struct cache_entry **cache,
> int nr,
> * Set/Clear CE_NEW_SKIP_WORKTREE according to $GIT_DIR/info/sparse-checkout
> */
> static void mark_new_skip_worktree(struct exclude_list *el,
> - struct index_state *the_index,
> + struct index_state *istate,
> int select_flag, int skip_wt_flag)
> {
> int i;
> @@ -1240,8 +1240,8 @@ static void mark_new_skip_worktree(struct exclude_list
> *el,
> * 1. Pretend the narrowest worktree: only unmerged entries
> * are checked out
> */
> - for (i = 0; i < the_index->cache_nr; i++) {
> - struct cache_entry *ce = the_index->cache[i];
> + for (i = 0; i < istate->cache_nr; i++) {
> + struct cache_entry *ce = istate->cache[i];
>
> if (select_flag && !(ce->ce_flags & select_flag))
> continue;
> @@ -1256,8 +1256,7 @@ static void mark_new_skip_worktree(struct exclude_list
> *el,
> * 2. Widen worktree according to sparse-checkout file.
> * Matched entries will have skip_wt_flag cleared (i.e. "in")
> */
> - clear_ce_flags(the_index->cache, the_index->cache_nr,
> - select_flag, skip_wt_flag, el);
> + clear_ce_flags(istate, select_flag, skip_wt_flag, el);
This looks a bit suspect. The clear_ce_flags() function has
not been modified to take a 'struct index_state *' as its first
parameter, right? (If you look back at the first hunk header, you
will see that it still takes 'struct cache_entry **, int, ...') ;-)
ATB,
Ramsay Jones