From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id DC5EB207F8 for ; Sat, 6 May 2017 22:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754677AbdEFWLy (ORCPT ); Sat, 6 May 2017 18:11:54 -0400 Received: from castro.crustytoothpaste.net ([75.10.60.170]:37612 "EHLO castro.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754223AbdEFWLQ (ORCPT ); Sat, 6 May 2017 18:11:16 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:254c:7dd1:74c7:cde0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by castro.crustytoothpaste.net (Postfix) with ESMTPSA id 18787280BE; Sat, 6 May 2017 22:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=crustytoothpaste.net; s=default; t=1494108670; bh=heg7nrZaNhcP64HrHIH63j2VIJtZsMo2naMPWspPmfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KQxz7dEUYzowy9G6iJJ8mN0P7MJ115CttOMNn4Iz8buuVOuRK9HcmUJZL2mpBnA5K JH2Cn9/meek805qdDQD5/JZsbiA2t2kefLg4yXd2AREQtzQvlQYvkArxgogip+7rbz JUq/mKTqi9SRGi+xzCumJ2qySL+iUX3nE27hTgZWSP2ArkbnVwQHfVZClp+5RHTLGe R+AI3CI1UI05ODsmccLbmnMBSCxrxuGyKQxECKHqFD6g43Cul6sF9HC5pDcxfRhM2z UF5Wvq9FpI6GFKNw8twz2vC15K9fZAYcsWPLlJ6cLNGoyN0SpKWKd6ULldWOX+fJ3D EESiYIS8pT8HmxGfs8zb+LX6g355DeSk678gh6r6FbkhdZWFjtKKiiH48aukRCkSxY qUpvLMYz0T+HDSAh6CFYA40NNW3U5aPT+k0btNsNkgzz99YqwGL44+JdXKPcz4e2IG t0SvMW0jq+MGiuP0BFm84UttkBHZpNwje33i05dGMYjL95fN+2U From: "brian m. carlson" To: git@vger.kernel.org Cc: Michael Haggerty , Jonathan Tan , Stefan Beller , Jeff King , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= , Brandon Williams Subject: [PATCH v3 17/53] tag: convert parse_tag_buffer to struct object_id Date: Sat, 6 May 2017 22:10:02 +0000 Message-Id: <20170506221038.296722-18-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.13.0.rc1.294.g07d810a77f In-Reply-To: <20170506221038.296722-1-sandals@crustytoothpaste.net> References: <20170506221038.296722-1-sandals@crustytoothpaste.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Specify some constants in terms of GIT_SHA1_HEXSZ, and convert a get_sha1_hex into parse_oid_hex to avoid needing to specify additional constants. Signed-off-by: brian m. carlson --- tag.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tag.c b/tag.c index 243d1fdbb..625f5cd71 100644 --- a/tag.c +++ b/tag.c @@ -116,7 +116,7 @@ static unsigned long parse_tag_date(const char *buf, const char *tail) int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) { - unsigned char sha1[20]; + struct object_id oid; char type[20]; const char *bufptr = data; const char *tail = bufptr + size; @@ -126,11 +126,10 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) return 0; item->object.parsed = 1; - if (size < 64) + if (size < GIT_SHA1_HEXSZ + 24) return -1; - if (memcmp("object ", bufptr, 7) || get_sha1_hex(bufptr + 7, sha1) || bufptr[47] != '\n') + if (memcmp("object ", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\n') return -1; - bufptr += 48; /* "object " + sha1 + "\n" */ if (!starts_with(bufptr, "type ")) return -1; @@ -143,13 +142,13 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) bufptr = nl + 1; if (!strcmp(type, blob_type)) { - item->tagged = &lookup_blob(sha1)->object; + item->tagged = &lookup_blob(oid.hash)->object; } else if (!strcmp(type, tree_type)) { - item->tagged = &lookup_tree(sha1)->object; + item->tagged = &lookup_tree(oid.hash)->object; } else if (!strcmp(type, commit_type)) { - item->tagged = &lookup_commit(sha1)->object; + item->tagged = &lookup_commit(oid.hash)->object; } else if (!strcmp(type, tag_type)) { - item->tagged = &lookup_tag(sha1)->object; + item->tagged = &lookup_tag(oid.hash)->object; } else { error("Unknown type %s", type); item->tagged = NULL;