Re: [PATCH 22/48] merge-recursive: Fix sorting order and directory change assumptions

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

 



Elijah Newren <newren@xxxxxxxxx> writes:

> We cannot assume that directory/file conflicts will appear in sorted
> order; for example, 'letters.txt' comes between 'letters' and
> 'letters/file'.
>
> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  merge-recursive.c   |   31 ++++++++++++++++++++++++++-----
>  t/t6020-merge-df.sh |   26 ++++++++++++++++++--------
>  2 files changed, 44 insertions(+), 13 deletions(-)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index 4771fb4..ed1fdb2 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -333,6 +333,28 @@ static struct string_list *get_unmerged(void)
>  	return unmerged;
>  }
>  
> +static int string_list_df_name_compare(const void *a, const void *b)
> +{
> +	const struct string_list_item *one = a;
> +	const struct string_list_item *two = b;
> +	/*
> +	 * Here we only care that entries for D/F conflicts are
> +	 * adjacent, in particular with the file of the D/F conflict
> +	 * appearing before files below the corresponding directory.
> +	 * The order of the rest of the list is irrelevant for us.
> +	 *
> +	 * To achieve this, we sort with df_name_compare and provide
> +	 * the mode S_IFDIR so that D/F conflicts will sort correctly.
> +	 * We use the mode S_IFDIR for everything else for simplicity,
> +	 * since in other cases any changes in their order due to
> +	 * sorting cause no problems for us.
> +	 */

I recall there was an issue of this sorting reported earlier...

> diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh
> index eec8f4e..27c3d73 100755
> --- a/t/t6020-merge-df.sh
> +++ b/t/t6020-merge-df.sh
> @@ -59,15 +59,19 @@ test_expect_success 'setup modify/delete + directory/file conflict' '
>  	git add letters &&
>  	git commit -m initial &&
>  
> +	# Throw in letters.txt for sorting order fun
> +	# ("letters.txt" sorts between "letters" and "letters/file")
>  	echo i >>letters &&
> -	git add letters &&
> +	echo "version 2" >letters.txt &&
> +	git add letters letters.txt &&

Nice.
--
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]