From patchwork Mon Oct 8 21:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10631543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFC9B15E8 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D238229B45 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C68E629B4F; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A8B729B45 for ; Mon, 8 Oct 2018 21:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbeJIFLJ (ORCPT ); Tue, 9 Oct 2018 01:11:09 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:49340 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbeJIFLF (ORCPT ); Tue, 9 Oct 2018 01:11:05 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:e17d:6d35:bfb8:6a25]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 8B32160788; Mon, 8 Oct 2018 21:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1539035835; bh=VRLjC3u3UxT6bbCxIljy6X2n2kesAyJuv3+EwlcMsTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=xkHVrBD4WRkv/lVS83veKEcBy3v8vD1NwpMdB3m8L8nFp5HmrEY15lod+Iq4kfvCm nBeu3so8/Cc+U+CI68Mr/Yjkok5bwS/RsrMPToeOsvjJGoCtFb83NtVhBqB5EjMIF2 oNeHRR6JsuaZ3aAFPJhA8c3Ol8YGx+EA7LPugqdaNZ9gTEc1ft6LjtyQqBl0x4+96r cYRjwqV0fe52uBtkV3LvhJ/xT6fZwQH3+ik07auwQKQc148+JsI1qxxAZlzXf9dxKB QehLqRcdLJPn1SQKVSMFPYh6gk8jjxD7XxACFFb5P6iB23Z0VIEyeZZNjw/FSoJnop GSbY3grfhizyeeJ8AUQCLPeHrvEHXCBex5hyMR9y9DxcHgxYIUlGgALWLqhhEYg/hT d7sg1msMAU5G981InR/4xGa3vaCkk8eG22lfstEKezzvZ6uoR0JFY2NdnJWKiMV33C p/PxLsNnx7jzErOQwHyGdQZ1rk+8Q/Ybp7XV5BkJ/x1jp0KlEl6 From: "brian m. carlson" To: git@vger.kernel.org Cc: Jeff King , Eric Sunshine , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 09/14] transport: use parse_oid_hex instead of a constant Date: Mon, 8 Oct 2018 21:56:56 +0000 Message-Id: <20181008215701.779099-10-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c In-Reply-To: <20181008215701.779099-1-sandals@crustytoothpaste.net> References: <20181008215701.779099-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use parse_oid_hex to compute a pointer instead of using GIT_SHA1_HEXSZ. This simplifies the code and makes it independent of the hash length. Signed-off-by: brian m. carlson --- transport.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transport.c b/transport.c index 1c76d64aba..44b9ddf670 100644 --- a/transport.c +++ b/transport.c @@ -1346,15 +1346,16 @@ static void read_alternate_refs(const char *path, fh = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, fh) != EOF) { struct object_id oid; + const char *p; - if (get_oid_hex(line.buf, &oid) || - line.buf[GIT_SHA1_HEXSZ] != ' ') { + if (parse_oid_hex(line.buf, &oid, &p) || + *p != ' ') { warning(_("invalid line while parsing alternate refs: %s"), line.buf); break; } - cb(line.buf + GIT_SHA1_HEXSZ + 1, &oid, data); + cb(p + 1, &oid, data); } fclose(fh);