Re: [PATCH v3 16/17] fsck: report invalid types recorded in objects

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

 



> diff --git a/object-store.h b/object-store.h
> index 698a701d70..ba6e5d76c0 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -376,6 +376,7 @@ int oid_object_info_extended(struct repository *r,
>  
>  /*
>   * Open the loose object at path, check its hash, and return the contents,
> + * use the "oi" argument to assert things about the object, or e.g. populate its
>   * type, and size. If the object is a blob, then "contents" may return NULL,
>   * to allow streaming of large blobs.
>   *
> @@ -383,9 +384,8 @@ int oid_object_info_extended(struct repository *r,
>   */
>  int read_loose_object(const char *path,
>  		      const struct object_id *expected_oid,
> -		      enum object_type *type,
> -		      unsigned long *size,
>  		      void **contents,
> +		      struct object_info *oi,
>  		      unsigned int oi_flags);
>  
>  /*

What do you mean by using "oi" to assert things? As far as I know, it's
just a way to specify which information you want (by assigning pointers
to the appropriate fields).

> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index e7e8decebb..bc541af2cf 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh
> @@ -66,6 +66,25 @@ test_expect_success 'object with hash mismatch' '
>  	)
>  '
>  
> +test_expect_success 'object with hash and type mismatch' '
> +	test_create_repo hash-type-mismatch &&
> +	(
> +		cd hash-type-mismatch &&
> +		oid=$(echo blob | git hash-object -w --stdin -t garbage --literally) &&
> +		old=$(test_oid_to_path "$oid") &&
> +		new=$(dirname $old)/$(test_oid ff_2) &&
> +		oid="$(dirname $new)$(basename $new)" &&
> +		mv .git/objects/$old .git/objects/$new &&
> +		git update-index --add --cacheinfo 100644 $oid foo &&
> +		tree=$(git write-tree) &&
> +		cmt=$(echo bogus | git commit-tree $tree) &&
> +		git update-ref refs/heads/bogus $cmt &&
> +		test_must_fail git fsck 2>out &&
> +		grep "^error: hash mismatch for " out &&
> +		grep "^error: $oid: object is of unknown type '"'"'garbage'"'"'" out

I don't think we need to know the precise quote used - it's simpler to
just put "." where we need the single quote. Same for the other case
below.



[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