Re: [PATCH v2 07/14] match-trees: convert splice_tree to object_id

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

 



On Mon, Jan 22, 2018 at 12:04:30PM +0100, Patryk Obara wrote:
> Convert the definition of static recursive splice_tree function to use
> struct object_id and adjust single caller.
> 
> Signed-off-by: Patryk Obara <patryk.obara@xxxxxxxxx>
> ---
>  match-trees.c | 42 ++++++++++++++++++++----------------------
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/match-trees.c b/match-trees.c
> index 396b7338df..0f899a7212 100644
> --- a/match-trees.c
> +++ b/match-trees.c
> @@ -161,19 +161,17 @@ static void match_trees(const struct object_id *hash1,
>   * A tree "hash1" has a subdirectory at "prefix".  Come up with a
>   * tree object by replacing it with another tree "hash2".
>   */
> -static int splice_tree(const unsigned char *hash1,
> -		       const char *prefix,
> -		       const unsigned char *hash2,
> -		       unsigned char *result)
> +static int splice_tree(const struct object_id *hash1, const char *prefix,
> +		       const struct object_id *hash2, struct object_id *result)

Maybe change the names to oid1 and oid2 too. I had a "what?" moment
when I read hash1->hash below.

> @@ -197,26 +195,26 @@ static int splice_tree(const unsigned char *hash1,
>  		if (strlen(name) == toplen &&
>  		    !memcmp(name, prefix, toplen)) {
>  			if (!S_ISDIR(mode))
> -				die("entry %s in tree %s is not a tree",
> -				    name, sha1_to_hex(hash1));
> -			rewrite_here = (unsigned char *) oid->hash;
> +				die("entry %s in tree %s is not a tree", name,
> +				    oid_to_hex(hash1));
> +			rewrite_here = (struct object_id *)oid;

You don't need the typecast here anymore, do you?

--
Duy



[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