From patchwork Tue Jan 15 00:39:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10763665 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 6F3256C2 for ; Tue, 15 Jan 2019 00:40:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 613192C11D for ; Tue, 15 Jan 2019 00:40:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 558462C124; Tue, 15 Jan 2019 00:40:12 +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 03ADA2C11D for ; Tue, 15 Jan 2019 00:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbfAOAkK (ORCPT ); Mon, 14 Jan 2019 19:40:10 -0500 Received: from injection.crustytoothpaste.net ([192.241.140.119]:59212 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfAOAkK (ORCPT ); Mon, 14 Jan 2019 19:40:10 -0500 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:c162:ac20:e47c:bd21]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 7919E60FE0; Tue, 15 Jan 2019 00:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1547512808; bh=ggXze6EIKai+XFoz5ubIpnH4KMm03oQE/Zqrrlge+MQ=; 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=BIfwbUScIq3vz25p8Ib0NgREraW9/dvrr25YyKL/Nzu7YPHzURVDEL9PzHrQUKH+t Is+aYekRpNf3UqxfiY/NudW8SoFqDiosHFXlFJe76ZOqbwmTIh14cg2Ex5o4g0mnSR yxoHVXA2/1221hWZqHUi5M27gXaIqIt0PepOLdesWsavbLxGO/N9gTUdSqc4Hz08VB 1B8vMfvz8Pbm4n7dS6ufRGgmurT+L6oIaFqH1lNvbdMcVnTDkkVWU9UnOiYEQjRE+8 hBxWTy4rYDDoqN1ZYDhXm71JlK+9eDDdE52+yVmiTMSAB4uVG+wjM9MWn0abNt+WNE 0j1FB+RAnaHmYSb1sHuWaFMGCWCsbZeEN2BfhywsHnDkcX8wZ96CvGyouvo2+EeMKq UPHQSiOn9ERJfcaO9r6JPXyQSkc4dsNeiX+Ibc2MN3r4NMHkS1Ru23W/+1d5W6cuxk Qoo24LyQrGH22ErDPqQRFUfshwF05tddJjbJctq45Vjtf9lCRZa From: "brian m. carlson" To: git@vger.kernel.org Cc: =?utf-8?q?Martin_=C3=85gren?= , Junio C Hamano , Jeff King Subject: [PATCH v2 2/5] match-trees: compute buffer offset correctly when splicing Date: Tue, 15 Jan 2019 00:39:42 +0000 Message-Id: <20190115003946.932078-3-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.20.1.321.g9e740568ce In-Reply-To: <20190115003946.932078-1-sandals@crustytoothpaste.net> References: <20190115003946.932078-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 Currently, the struct object_id pointer returned from tree_entry_extract lives directly inside the parsed tree buffer. In a future commit, this will change so that it instead points to a dedicated struct member. Since in this code path, we want to modify the buffer directly, compute the buffer offset we want to modify by using the pointer to the path instead. Signed-off-by: brian m. carlson --- match-trees.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/match-trees.c b/match-trees.c index 2b6d31ef9d..feca48a5fd 100644 --- a/match-trees.c +++ b/match-trees.c @@ -199,15 +199,16 @@ static int splice_tree(const struct object_id *oid1, const char *prefix, while (desc.size) { const char *name; unsigned mode; - const struct object_id *oid; - oid = tree_entry_extract(&desc, &name, &mode); + tree_entry_extract(&desc, &name, &mode); if (strlen(name) == toplen && !memcmp(name, prefix, toplen)) { if (!S_ISDIR(mode)) die("entry %s in tree %s is not a tree", name, oid_to_hex(oid1)); - rewrite_here = (struct object_id *)oid; + rewrite_here = (struct object_id *)(desc.entry.path + + strlen(desc.entry.path) + + 1); break; } update_tree_entry(&desc);