From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id EF72C1F62E for ; Tue, 15 Jan 2019 00:40:11 +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=20=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 Content-Transfer-Encoding: 8bit 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 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);