Re: [PATCH v5 2/3] bundle: lost objects when removing duplicate pendings
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 11, 2021, 20:12 UTC
- Message-ID
- <xmqqwnwj6xnu.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20210110143019.5625-3-worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> 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.
Show 36 quoted lines
> -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