Re: [PATCH v5 2/3] bundle: lost objects when removing duplicate pendings

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

 



Jiang Xin <worldhello.net@xxxxxxxxx> writes:

>  /*
> - * Return true iff array already contains an entry with name.
> + * Return true if array already contains an entry.
>   */

I think the original deliberately spells "if and only if", but a
natural reading of "return true if X" would be "this would never
return true if not X", so perhaps the above change is OK.

> -static int contains_name(struct object_array *array, const char *name)
> +static int contains_object(struct object_array *array,
> +			   const struct object *item, const char *name)
>  {
>  	unsigned nr = array->nr, i;
>  	struct object_array_entry *object = array->objects;
>  
>  	for (i = 0; i < nr; i++, object++)
> -		if (!strcmp(object->name, name))
> +		if (item == object->item && !strcmp(object->name, name))
>  			return 1;
>  	return 0;
>  }
> @@ -432,7 +433,8 @@ void object_array_remove_duplicates(struct object_array *array)
>  
>  	array->nr = 0;
>  	for (src = 0; src < nr; src++) {
> -		if (!contains_name(array, objects[src].name)) {
> +		if (!contains_object(array, objects[src].item,
> +				     objects[src].name)) {
>  			if (src != array->nr)
>  				objects[array->nr] = objects[src];
>  			array->nr++;
> diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh
> index 637cdb5a8e..5c9d5ed94d 100755
> --- a/t/t6020-bundle-misc.sh
> +++ b/t/t6020-bundle-misc.sh
> @@ -169,7 +169,7 @@ test_expect_success 'setup' '
>  	test_commit_setvar P "Commit P" main.txt
>  '
>  
> -test_expect_failure 'create bundle from special rev: main^!' '
> +test_expect_success 'create bundle from special rev: main^!' '
>  	git bundle create special-rev.bdl "main^!" &&
>  
>  	git bundle list-heads special-rev.bdl |
n



[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