Re: [PATCH 4/4] submodule: submodule_move_head omits old argument in forced case

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

 



Stefan Beller <sbeller@xxxxxxxxxx> writes:

> When using hard reset or forced checkout with the option to recurse into
> submodules, the submodules need to be reset, too.
>
> It turns out that we need to omit the duplicate old argument to read-tree
> in all forced cases to omit the 2 way merge and use the more assertive
> behavior of reading the specific new tree into the index and updating
> the working tree.

The phrase "the more assertive" made me imagine something like
"reset --hard", which resurrect lost paths and also get rid of added
paths.  "reading the specific new tree into the index" smells more
like "checkout $tree-ish $paths" that has an overlay semantics, that
resurrects lost paths but does not get rid of added paths.

Perhaps not just "rm sub1/file1" but also add a new file that is not
in HEAD to ensure that it will be blown away when $command is run
to ensure that we got the distinction between the two right?

>
> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
> ---
>  submodule.c               |  4 +++-
>  t/lib-submodule-update.sh | 11 +++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/submodule.c b/submodule.c
> index fa25888783..db0f7ac51e 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1653,7 +1653,9 @@ int submodule_move_head(const char *path,
>  	else
>  		argv_array_push(&cp.args, "-m");
>  
> -	argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
> +	if (!(flags & SUBMODULE_MOVE_HEAD_FORCE))
> +		argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
> +
>  	argv_array_push(&cp.args, new ? new : EMPTY_TREE_SHA1_HEX);
>  
>  	if (run_command(&cp)) {
> diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
> index fb0173ea87..380ef4b4ae 100755
> --- a/t/lib-submodule-update.sh
> +++ b/t/lib-submodule-update.sh
> @@ -1015,4 +1015,15 @@ test_submodule_forced_switch_recursing_with_args () {
>  			test_submodule_content sub1 origin/modify_sub1
>  		)
>  	'
> +
> +	test_expect_success "$command: changed submodule worktree is reset" '
> +		prolog &&
> +		reset_work_tree_to_interested add_sub1 &&
> +		(
> +			cd submodule_update &&
> +			rm sub1/file1 &&
> +			$command HEAD &&
> +			test_path_is_file sub1/file1
> +		)
> +	'
>  }



[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