Re: [RFC/PATCH 04/18] merge-octopus: Abort if index not clean

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

 



Elijah Newren <newren@xxxxxxxxx> writes:

> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  git-merge-octopus.sh                     |  5 +++++
>  t/t6044-merge-unrelated-index-changes.sh | 21 ++++++---------------
>  2 files changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
> index 8643f74..a1d7702 100755
> --- a/git-merge-octopus.sh
> +++ b/git-merge-octopus.sh
> @@ -44,6 +44,11 @@ esac
>  # MRC is the current "merge reference commit"
>  # MRT is the current "merge result tree"
>  
> +if ! git diff-index --quiet --cached HEAD --; then

Style.

> +    echo "Error: Your local changes to the following files need to be resolved before merge"
> +    git diff-index --cached --name-only HEAD -- | sed -e 's/^/    /'
> +    exit 2
> +fi

Unless they are existing conflicts, the word "resolve" is misleading.

Erroring it out may not strictly be necessary (i.e. as Octopus is
meant to be used only when changes from the branches do not overlap,
it is likely that all of them are small simple changes that do not
touch any path that you currently have local modifications in the
index), but I do not think it is worth the effort to identify safe
cases that can continue, so I agree that this change to abort the
merge is a sensible one.



>  MRC=$(git rev-parse --verify -q $head)
>  MRT=$(git write-tree)
>  NON_FF_MERGE=0
> diff --git a/t/t6044-merge-unrelated-index-changes.sh b/t/t6044-merge-unrelated-index-changes.sh
> index 726c898..4c1dc5a 100755
> --- a/t/t6044-merge-unrelated-index-changes.sh
> +++ b/t/t6044-merge-unrelated-index-changes.sh
> @@ -105,43 +105,34 @@ test_expect_success 'recursive' '
>  	test_must_fail git merge -s recursive C^0
>  '
>  
> -test_expect_failure 'octopus, unrelated file touched' '
> +test_expect_success 'octopus, unrelated file touched' '
>  	git reset --hard &&
>  	git checkout B^0 &&
>  
>  	touch random_file && git add random_file &&
>  
>  	echo "I think the next line should fail, but maybe it was intended..." &&
> -	test_might_fail git merge C^0 D^0 &&
> -
> -	echo "No matter what, random_file should NOT be part of HEAD" &&
> -	test_must_fail git rev-parse HEAD:random_file
> +	test_must_fail git merge C^0 D^0
>  '
>  
> -test_expect_failure 'octopus, related file removed' '
> +test_expect_success 'octopus, related file removed' '
>  	git reset --hard &&
>  	git checkout B^0 &&
>  
>  	git rm b &&
>  
>  	echo "I think the next line should fail, but maybe it was intended..." &&
> -	test_might_fail git merge C^0 D^0 &&
> -
> -	echo "No matter what, b should still be in HEAD" &&
> -	git cat-file -p HEAD:b | grep b$
> +	test_must_fail git merge C^0 D^0
>  '
>  
> -test_expect_failure 'octopus, related file modified' '
> +test_expect_success 'octopus, related file modified' '
>  	git reset --hard &&
>  	git checkout B^0 &&
>  
>  	echo 12 >>a && git add a &&
>  
>  	echo "I think the next line should fail, but maybe it was intended..." &&
> -	test_might_fail git merge C^0 D^0 &&
> -
> -	echo "No matter what, 12 should NOT be in the copy of a from HEAD" &&
> -	git cat-file -p HEAD:a | test_must_fail grep 12
> +	test_must_fail git merge C^0 D^0
>  '
>  
>  test_expect_success 'ours' '
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]