Re: [PATCH v4 2/2] merge-recursive: fix the refresh logic in update_file_flags

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

 



"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Elijah Newren <newren@xxxxxxxxx>
>
> If we need to delete a higher stage entry in the index to place the file
> at stage 0, then we'll lose that file's stat information.  In such
> situations we may still be able to detect that the file on disk is the
> version we want (as noted by our comment in the code:
>   /* do not overwrite file if already present */
> ), but we do still need to update the mtime since we are creating a new
> cache_entry for that file.  Update the logic used to determine whether
> we refresh a file's mtime.
>
> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  merge-recursive.c                    | 7 +++++--
>  t/t3433-rebase-across-mode-change.sh | 2 +-
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index aee1769a7ac..e6f943c5ccc 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -998,10 +998,13 @@ static int update_file_flags(struct merge_options *opt,
>  		free(buf);
>  	}
>  update_index:
> -	if (!ret && update_cache)
> -		if (add_cacheinfo(opt, contents, path, 0, update_wd,
> +	if (!ret && update_cache) {
> +		int refresh = (!opt->priv->call_depth &&
> +			       contents->mode != S_IFGITLINK);
> +		if (add_cacheinfo(opt, contents, path, 0, refresh,
>  				  ADD_CACHE_OK_TO_ADD))
>  			return -1;

Hmph, !.call_depth would avoid resetting update_wd to 0, so the only
difference this patch makes is when the caller of this helper passed
(update_wd == 0) during the outermost merge.  We did not tell
add_cacheinfo() to refresh, and refresh_cache_entry() was not
called.  But the new code forces refresh to happen for normal
entries.  The proposed log message explains that a refresh is needed
for a new cache entry, but if I am reading the code correctly, this
function is called with !update_wd from two places, one of which is
the "Adding %s" /* do not overwrite ... */ the log message mentions.

But the other one?  When both sides added identically, we do have an
up-to-date result on our side already, so shouldn't we avoid forcing
update_wd in that case?

I do not think passing refresh==1 in that case will produce an
incorrect result, but doesn't it force an unnecessary refreshing?

Puzzled.

> +	}
>  	return ret;
>  }
>  
> diff --git a/t/t3433-rebase-across-mode-change.sh b/t/t3433-rebase-across-mode-change.sh
> index f11fc35c3ee..05df964670f 100755
> --- a/t/t3433-rebase-across-mode-change.sh
> +++ b/t/t3433-rebase-across-mode-change.sh
> @@ -33,7 +33,7 @@ test_expect_success 'rebase changes with the apply backend' '
>  	git rebase side1
>  '
>  
> -test_expect_failure 'rebase changes with the merge backend' '
> +test_expect_success 'rebase changes with the merge backend' '
>  	test_when_finished "git rebase --abort || true" &&
>  	git checkout -b merge-backend side2 &&
>  	git rebase -m side1



[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