From patchwork Fri Feb 23 08:34:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568728 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F5B1A731 for ; Fri, 23 Feb 2024 08:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677272; cv=none; b=lDRTaJQQdpMyHyr4M2ctvldHChpJpvTI6bOShKKNFjnr/moR6qHwujKH+5xhJK1JwUmf0dNJkUd2K5A0MklFJol1iwt1PF6Rankmz2ZsI5X1/v3mQwX9BZlyaRFNAnDxgcjnlJqc3qglnm/oymZrvRiZ9a15YbHl+4nD5aTJfD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677272; c=relaxed/simple; bh=CWSOJRx5fGiD+VWfre6qxlFaVX4Agto1Xz0sb8/ndRc=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Loa4ibhUJH03brz4mdrOD3UPaXvKzG5R7Z9RrnshQ50k1yz/G6xdIa8gWHPnZeLxi1elgW1ewQupcvogSOU9ilJWUXvIweBkf3E7bB+tCxfGwPKNeMSnw08/IEnArUZUSIFsotRhzvmxpRCr8Z2CHBPEPgFF05bTEKv1Tkt8oFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OVVBrnkA; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OVVBrnkA" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5129e5b8cecso797074e87.3 for ; Fri, 23 Feb 2024 00:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677268; x=1709282068; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FwYeaUigHoLqe07Dyr7OAsD6q6DCJT125jNN3V4+eZs=; b=OVVBrnkAAAo/U95xA6zDfZu3P1sQzU8fxTl0ziHM75vD0pZMNYP/pq2mCi2W5C4AAB badcQC9FVipal0vdc9SCyAHcgrzifGqGDOU/iLT6ktlGzO071XveZ/nfXRoV/6klQe2j fJo9/NYLzqATgq9w0utsHLR7drLhoHUOJpnFqktxV36GIk2EZRoiq3JiVKWDyYn9dl2V gChRAqnvq6LMafVH2myIwgAhw7dx6KgefKF6uQhq5KN0snT7ohdJ2Nm+FJH3gqBpZfbE 6nGrnmyRZGRdLSdVoaOWqClSesVqdgsshMwZ+D1L8gN1BFa2/JleeRLzcD0P+C+K2f8w kXew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677268; x=1709282068; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FwYeaUigHoLqe07Dyr7OAsD6q6DCJT125jNN3V4+eZs=; b=YM7VFXrxM+vM3xgLLgG4iUFbin3YdnDSvU+ii8u6ojDmWqmzvQIZLGHjCc5NWLiGMR tQXUqcbDelbZsMBW1UiEsS8ISdDugIq1mLkMJFA+4rJXWt7/ptGGTlF7RLLAbV+6aB+s Enf8cfOq1Y3M/p8pY7oQEa410mKYjNoqZJuo0N3Fbrpn+dX1t/6ULeMQlZMTKvUnMoAx ZSaBhVtZ618Vv/q60GwGZ9kSTA/pzh7qLt17gb53w/FHHYyf8zVZvz0tjAbLYmei+aB7 sHQTtzpG/4KoeLfOI/Rv0jePuPOR6w2dRNva8STWTZbveZD4cQmK1Fw3Db2q2mg1ENjG qz0g== X-Gm-Message-State: AOJu0Yw69cjih03ENjrVlGINS/ZQY2+JiIqlojSpinWRA88tS1WPJEYX K20kw28dS0wbURxcIA9ib+asvSiieoFeEoQcWqdaQnc37FFduN/O+ooHXEar X-Google-Smtp-Source: AGHT+IF2cQIE/VnSn3dLFpAQ6CDTt6kIVHlk+P6V+6Dl230/oczMgdx+ZeJ1uGwDTyLShRkO5ntTaQ== X-Received: by 2002:a19:691d:0:b0:512:a2c7:e44c with SMTP id e29-20020a19691d000000b00512a2c7e44cmr741422lfc.20.1708677268176; Fri, 23 Feb 2024 00:34:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bh9-20020a05600c3d0900b00412945d2051sm1185185wmb.12.2024.02.23.00.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:27 -0800 (PST) Message-ID: <11b9cd8c5da5e6792ce940ea29d2e93e57731555.1708677266.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:20 +0000 Subject: [PATCH v4 1/6] merge-tree: fail with a non-zero exit code on missing tree objects Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin When `git merge-tree` encounters a missing tree object, it should error out and not continue quietly as if nothing had happened. However, as of time of writing, `git merge-tree` _does_ continue, and then offers the empty tree as result. Let's fix this. Signed-off-by: Johannes Schindelin --- merge-ort.c | 7 ++++--- t/t4301-merge-tree-write-tree.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 6491070d965..c37fc035f13 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1659,9 +1659,10 @@ static int collect_merge_info(struct merge_options *opt, info.data = opt; info.show_all_errors = 1; - parse_tree(merge_base); - parse_tree(side1); - parse_tree(side2); + if (parse_tree(merge_base) < 0 || + parse_tree(side1) < 0 || + parse_tree(side2) < 0) + return -1; init_tree_desc(t + 0, merge_base->buffer, merge_base->size); init_tree_desc(t + 1, side1->buffer, side1->size); init_tree_desc(t + 2, side2->buffer, side2->size); diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index 7d0fa74da74..908c9b540c8 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -951,4 +951,15 @@ test_expect_success '--merge-base with tree OIDs' ' test_cmp with-commits with-trees ' +test_expect_success 'error out on missing tree objects' ' + git init --bare missing-tree.git && + git rev-list side3 >list && + git rev-parse side3^: >>list && + git pack-objects missing-tree.git/objects/pack/side3-tree-is-missing actual 2>err && + test_grep "Could not read $(git rev-parse $side3:)" err && + test_must_be_empty actual +' + test_done From patchwork Fri Feb 23 08:34:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568729 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D642E17C96 for ; Fri, 23 Feb 2024 08:34:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677273; cv=none; b=sonveGNIzUwPzJWyQeG6rJOepBU5bHq1UTRXpjwSXgZVF5FEmEXY96YtWfx6TP+JlSR+0kvgaRD/C+/LpuVzS5DiTf43VRG8i6LcqRihLhN/tdTLd03f8H4zx6roOTAnJlBB4vqgewcm5OaEpB+Gdo3o+QspsLoICsMBYsD2kpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677273; c=relaxed/simple; bh=Xq7WRXhxo0C1kRAmZ99K0pnF6HJm4Bw5bwfBCsQ5cn4=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=TOmSC41aWuO0Gr1pQNfSMInEeSkLu43ggxjrILLVWcRm9fcV1ZlbVuR1Bd18AOnwxeZHnwTGgwoRoO35Kv7H0adEJaoD19UeoHy4UgH/zhm/MC5Ps+GiUtERgar72n0jLD+Ukggx5Jey4fIN7egbW3dSXaRLx/99N+a359wyWGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QiwbhtUr; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QiwbhtUr" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-512d8fe4fceso664832e87.3 for ; Fri, 23 Feb 2024 00:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677270; x=1709282070; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=3+i8PkXYJCTRN8cYGZeTF3cwl+HgYBrV1XX86X8PXc4=; b=QiwbhtUr48WoUmB1os+NaQqi/HKRbO8dpbPrVqbPw1e1xTHJA4aE0nR5EgDrNz4qng EAzANV9pOjxjgR1Uwd3LJrflMtcX9RCc8AcVio9pQhEq27x4lnO+UXPHxrVuITUDplZw toqEv8c4N/qvxRw5NCYdZEUAy1ltD3eFrQTzPvXQ4sx9q+mRwHBzyTXm3uwqzlp5Wveu J/r39NvRalcIUipWrjh1HPkE5phUfnbcE70IiUUkda5Pkh6rJWr6P2zFFKOmdOipx7NB ORQLlv5cpiz9IfbnMwM27S/fycPOHPLeGclr7GtepV6I8LRUfIqXMnrWsA5u9UwtmPn6 AdPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677270; x=1709282070; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3+i8PkXYJCTRN8cYGZeTF3cwl+HgYBrV1XX86X8PXc4=; b=WBSR21OtuotsXfU/Pcvit+OxYGMVeWr329YqAfyX70kgaRDM3dhLzA2g6Ultq9n9+y SBHeO949Cfo0tFxxXr2+l594829taC4/T7UjIHeRx9BHZhc6Us1pSWcKshx/DJTMxhES VSl0O8I4Wt5MLHCUhwwFuOv18937s4VCNj4MFE6Ix5uVsX1KsB3cMW71pISekeHRLzjl 0brJQtFGNsojvEbqxCCikwNeTgM1J1nBZ375SWKEIYTT6k3qG2x68v4x9nkZWqZKhBX4 HpW26XL1ryS2pKl4aunCQ1Noqfwg5MUAX1qA+s2RxQvPIOukXy0mUyCqZhQf53MX0vQk kOqA== X-Gm-Message-State: AOJu0YwwxzfIOHIc0TMSku4tTSRdcpBL/6KIox341X0a8hB6hkUOGikg kQtKYvRpMA3T+75buASYn8BfHHd03W4W5MPL2G9e2kfUNJ2cKXwPNtk+qyjZ X-Google-Smtp-Source: AGHT+IGnhKAL1ZnaWVCGaDvm8HrxY2HE7n1w3Pa15wWEFO/r4muYX8Z1XPKxW3donfgI7QLH2TN+CA== X-Received: by 2002:a19:ca4b:0:b0:512:8881:8f6b with SMTP id h11-20020a19ca4b000000b0051288818f6bmr997553lfj.36.1708677269635; Fri, 23 Feb 2024 00:34:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b004128808db91sm1521065wmb.23.2024.02.23.00.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:28 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:21 +0000 Subject: [PATCH v4 2/6] merge-ort: do check `parse_tree()`'s return value Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The previous commit fixed a bug where a missing tree was reported, but not treated as an error. This patch addresses the same issue for the remaining two callers of `parse_tree()`. This change is not accompanied by a regression test because the code in question is only reached at the `checkout` stage, i.e. after the merge has happened (and therefore the tree objects could only be missing if the disk had gone bad in that short time window, or something similarly tricky to recreate in the test suite). Signed-off-by: Johannes Schindelin --- merge-ort.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index c37fc035f13..79d9e18f63d 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4379,9 +4379,11 @@ static int checkout(struct merge_options *opt, unpack_opts.verbose_update = (opt->verbosity > 2); unpack_opts.fn = twoway_merge; unpack_opts.preserve_ignored = 0; /* FIXME: !opts->overwrite_ignore */ - parse_tree(prev); + if (parse_tree(prev) < 0) + return -1; init_tree_desc(&trees[0], prev->buffer, prev->size); - parse_tree(next); + if (parse_tree(next) < 0) + return -1; init_tree_desc(&trees[1], next->buffer, next->size); ret = unpack_trees(2, trees, &unpack_opts); From patchwork Fri Feb 23 08:34:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568730 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A503A1AAB9 for ; Fri, 23 Feb 2024 08:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677274; cv=none; b=ll13hvkIcSrPkpzlmDo0wX2VGcXPUIXWpXkbQkeYioBoX74hf0mXLQQvAjh7ddt55f547s+WXkx25Zl4UnmZgiviXIBJe5HG8lJyb1Ir8XcO8AzvrtkDEVrySQHIodEDHjMjJOiXsT78O+Av2ZDPFIuCkglr8wrNBamvvscgWWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677274; c=relaxed/simple; bh=C05rXEareOoDG82WPd99xJmYGLU1fbzABBWmtXJTWMY=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=WSr/KvjR5jwRypITNFXqlnNA6CrmFtfTqrZzEeprPyLCTSso3ffGQmz9whgn9iGd8JwmIMbzKSSEWxmSzxPkWoly+7eYpWKloGbGSnLp+RY0HNfxb1ybF3cPDCzwZWE3MrhmvAzW7scjpS35ZDP009oU+g+12GfLpjYztziVb1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WeI/Jo0E; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WeI/Jo0E" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33d153254b7so454646f8f.0 for ; Fri, 23 Feb 2024 00:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677270; x=1709282070; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=zzXXrTR1654PTduFx3oEOukzzhnQP7ss3KpbX4fLdqU=; b=WeI/Jo0EdGacBST5/Go2gWxlPeXWr7HJNU4KFUwryhhIxLigF/CbDOwG7HzOuWO8Wr E7WRp/e3+6PorsNBzTjNWiMDJjL/SxoZHizs119V3nDwWiPfUBqkCdXVkWvSYHoyv9TB q9KuTZxAwqmrhtAO9hyfypmTnmq+ZNsCNrlTDiBMIPkNHt06cdXUpxDf2AbmovBeZl4x SWGZXSAuXJl9APoH14ZFIzjawWv5R4L6NzaJb3+G5sOtgd8d+hPC9Lkb1hc0abVaZBub igH8wDvvstjCGlDod54kLmrHaplNDUMTfzxsb1fcgKtS920Y4fVhtwra2OFhhRPxJ821 exmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677270; x=1709282070; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zzXXrTR1654PTduFx3oEOukzzhnQP7ss3KpbX4fLdqU=; b=uZBlWgh2yfyaweEuLG5SrOYJgnmWYEeQG1ASMrxDDw7DFAz1M2GvI28jWoyK42J3gl b9xwNCy+EEivic45T4VSp6IW2a1AzHIy6hbCLzpfsDRR0gr1XJ/zn8BCzaVJYSaGHvT2 UGVmZclPWbuZHw8FpzXTh2w5ioOYOnc8PsFaoAWPxc+aezDf+tcXDY1KV2rkPO+CnJNE +j9/LqCBOYHFTdVFCxwliB2V3u+30g5KNB7tOZCiSBv5b2O4CBBJnIYQHHYEgmBHIk2Q 2z1IgyDMLnNmQRrZwcExuYjIKRsYe2Lk2x4t8h/hwY47K8MwY2yHax7ecXSyvyq1mjkh YOmQ== X-Gm-Message-State: AOJu0YyXoVVDT+oh+FBTngvCxPM41oYmaWixL78XDbBXczrrWIW5fjnv Mf8kxGmkzq9DqM5nCUR8vnNPq2Yf0t7KFHXzkbVW3l8LRw8Gudjlh2OhJj3X X-Google-Smtp-Source: AGHT+IG3mNVvJ6C5auHIwtGH4EX+ab4VvP6MPSj0CjCnfd1PEjp7NE27saWnPuCpLvspg+yFAEH4zA== X-Received: by 2002:a5d:4589:0:b0:33d:545b:1794 with SMTP id p9-20020a5d4589000000b0033d545b1794mr952375wrq.9.1708677270152; Fri, 23 Feb 2024 00:34:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r9-20020adff709000000b0033d8ce120f2sm1882029wrp.95.2024.02.23.00.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:29 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:22 +0000 Subject: [PATCH v4 3/6] t4301: verify that merge-tree fails on missing blob objects Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin We just fixed a problem where `merge-tree` would not fail on missing tree objects. Let's ensure that that problem does not occur with blob objects (and won't, in the future, either). Signed-off-by: Johannes Schindelin --- t/t4301-merge-tree-write-tree.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index 908c9b540c8..d4463a45706 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -962,4 +962,20 @@ test_expect_success 'error out on missing tree objects' ' test_must_be_empty actual ' +test_expect_success 'error out on missing blob objects' ' + echo 1 | git hash-object -w --stdin >blob1 && + echo 2 | git hash-object -w --stdin >blob2 && + echo 3 | git hash-object -w --stdin >blob3 && + printf "100644 blob $(cat blob1)\tblob\n" | git mktree >tree1 && + printf "100644 blob $(cat blob2)\tblob\n" | git mktree >tree2 && + printf "100644 blob $(cat blob3)\tblob\n" | git mktree >tree3 && + git init --bare missing-blob.git && + cat blob1 blob3 tree1 tree2 tree3 | + git pack-objects missing-blob.git/objects/pack/side1-whatever-is-missing && + test_must_fail git --git-dir=missing-blob.git >actual 2>err \ + merge-tree --merge-base=$(cat tree1) $(cat tree2) $(cat tree3) && + test_grep "unable to read blob object $(cat blob2)" err && + test_must_be_empty actual +' + test_done From patchwork Fri Feb 23 08:34:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568732 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 220621B598 for ; Fri, 23 Feb 2024 08:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677276; cv=none; b=QXPN5RebamhhZbT5Bf/DCWLPM1mdXZptdqA23mCSmdR2R/k2JcCMe4LIe+387ccN0gsXqal84BZHMZnKIAglWzQAHDKTNi1PBll6w4GRYvgV9BdpJJOaq8Y2W+uTrw5rw2eGJtKvph2h/HrNc+9IXtET1c4vYVQ/6JR8ZwE4KEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677276; c=relaxed/simple; bh=xFO640Fh+rm1jbBaHe53rGrBWZjTCVBI5rQIe52HUig=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=C7zCV1FZWDP+z1M1FGn3BQIBSaclyzxsx+92qUSiWZWNT/eDlAyHPTAXBboIeueYUxC3DYoaSL9G5ddbTfVI3J67QVNTCUH4z2zBolmAnAlUR3Lg/5PZikjySm07i1A8ZZ0wEd3Wq1WJ960VrNQcS5wFPPXSmAMvlj8+FJhz0rk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nOXdru9i; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nOXdru9i" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-512b13bf764so856210e87.0 for ; Fri, 23 Feb 2024 00:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677271; x=1709282071; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=TkH4jreFEObzu448xaus0SGNLlqiivck8SqNOgYuHfw=; b=nOXdru9iGSGRqlUopQt5laYLYNoC/lbrQoRPMV8+yIKaAqQuvLY4jDVxsCNhReVeQr NBbPARWX8H+OkgjQeha2rLPZxtuaSHEs8xwSIyhj7JUaQ+GLXNNE50XEdpTnD2X1JDG1 zTa80vDi6e8n6irco8NSQhw1WeIS+VIc6rGz6B4M2G6QjlSF+tlyF9pWnliYFi2Rlgqb 44Drmr2MYfeBPTt2bGoOvfB/T+QomphqoZyQM2oEMJ1PNXQtfdp0Jo1JNxtfsT7NiNqz JTQXbjQ3Ty2v/DUaIVuYLqcu+cYhhf+D4SGU0Xs5w9qLigjMJ6xZYe18svvgTFwkVEw2 hUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677271; x=1709282071; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TkH4jreFEObzu448xaus0SGNLlqiivck8SqNOgYuHfw=; b=eL4gTwvt+r5kK5C8WlOqzh4YqF3x57pz5+Glx4vyurcFr13ovVPhcRormykvETcAyt c7ip+lngyAoOQdRuAb9UT6w7eds35EaRmBfgwia52ur4WQ5jws0bc22ERIkf1ldDWcmj qENcyAWntpLttirCNUNPoRi7d3eZbEjte6cl1FK1SOLPUEHF3PE2w9evPIhgaplNZnap ErPQOIjkZyXjTNGXKCd63J+NTZmCO6+WXFIrXBmI+zMNX8UarCZ/BC5VY6UTM2E0RIb8 SRPhLUqdLCxSNczH+BDANR7RUvGGmDZ/D4Gdrlec5BVs2h1N7iYnn+Ghks6y1QOpDq9N Af5g== X-Gm-Message-State: AOJu0YxFM+/zx+G2YpcIb8FhWVgy6ISF/NBxc5k2OG8M8C8JU4jvto5B f/kG4fgWpN8Ihtfc0fZdnGZDRvrQB/Fmscy4zfwNB7oYCoAeKkyYFrODlfJQ X-Google-Smtp-Source: AGHT+IHqVrNAg4I50tl13Jk4ykKQGaq6evD11czwJ+vSmh9IWGMbHJEKQutjWJ5vdN1hXEjms38AKA== X-Received: by 2002:a05:6512:2394:b0:512:e303:c034 with SMTP id c20-20020a056512239400b00512e303c034mr1303872lfv.7.1708677270693; Fri, 23 Feb 2024 00:34:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l6-20020a1c7906000000b0040fddaf9ff4sm1443435wme.40.2024.02.23.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:30 -0800 (PST) Message-ID: <5942c27f4390d5bafea0a63f71b1193a57e8e770.1708677266.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:23 +0000 Subject: [PATCH v4 4/6] Always check `parse_tree*()`'s return value Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin Otherwise we may easily run into serious crashes: For example, if we run `init_tree_desc()` directly after a failed `parse_tree()`, we are accessing uninitialized data or trying to dereference `NULL`. Note that the `parse_tree()` function already takes care of showing an error message. The `parse_tree_indirectly()` and `repo_get_commit_tree()` functions do not, therefore those latter call sites need to show a useful error message while the former do not. Signed-off-by: Johannes Schindelin --- builtin/checkout.c | 19 ++++++++++++++++--- builtin/clone.c | 3 ++- builtin/commit.c | 3 ++- builtin/merge-tree.c | 6 ++++++ builtin/read-tree.c | 3 ++- builtin/reset.c | 4 ++++ cache-tree.c | 4 ++-- merge-ort.c | 3 +++ merge-recursive.c | 3 ++- merge.c | 5 ++++- reset.c | 5 +++++ sequencer.c | 4 ++++ 12 files changed, 52 insertions(+), 10 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index f02434bc155..9ab0901d629 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -707,7 +707,8 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o, init_checkout_metadata(&opts.meta, info->refname, info->commit ? &info->commit->object.oid : null_oid(), NULL); - parse_tree(tree); + if (parse_tree(tree) < 0) + return 128; init_tree_desc(&tree_desc, tree->buffer, tree->size); switch (unpack_trees(1, &tree_desc, &opts)) { case -2: @@ -786,9 +787,15 @@ static int merge_working_tree(const struct checkout_opts *opts, if (new_branch_info->commit) BUG("'switch --orphan' should never accept a commit as starting point"); new_tree = parse_tree_indirect(the_hash_algo->empty_tree); - } else + if (!new_tree) + BUG("unable to read empty tree"); + } else { new_tree = repo_get_commit_tree(the_repository, new_branch_info->commit); + if (!new_tree) + return error(_("unable to read tree (%s)"), + oid_to_hex(&new_branch_info->commit->object.oid)); + } if (opts->discard_changes) { ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info); if (ret) @@ -823,7 +830,8 @@ static int merge_working_tree(const struct checkout_opts *opts, oid_to_hex(old_commit_oid)); init_tree_desc(&trees[0], tree->buffer, tree->size); - parse_tree(new_tree); + if (parse_tree(new_tree) < 0) + exit(128); tree = new_tree; init_tree_desc(&trees[1], tree->buffer, tree->size); @@ -1239,10 +1247,15 @@ static void setup_new_branch_info_and_source_tree( if (!new_branch_info->commit) { /* not a commit */ *source_tree = parse_tree_indirect(rev); + if (!*source_tree) + die(_("unable to read tree (%s)"), oid_to_hex(rev)); } else { parse_commit_or_die(new_branch_info->commit); *source_tree = repo_get_commit_tree(the_repository, new_branch_info->commit); + if (!*source_tree) + die(_("unable to read tree (%s)"), + oid_to_hex(&new_branch_info->commit->object.oid)); } } diff --git a/builtin/clone.c b/builtin/clone.c index c6357af9498..4410b55be98 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -736,7 +736,8 @@ static int checkout(int submodule_progress, int filter_submodules) tree = parse_tree_indirect(&oid); if (!tree) die(_("unable to parse commit %s"), oid_to_hex(&oid)); - parse_tree(tree); + if (parse_tree(tree) < 0) + exit(128); init_tree_desc(&t, tree->buffer, tree->size); if (unpack_trees(1, &t, &opts) < 0) die(_("unable to checkout working tree")); diff --git a/builtin/commit.c b/builtin/commit.c index 781af2e206c..0723f06de7a 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -339,7 +339,8 @@ static void create_base_index(const struct commit *current_head) tree = parse_tree_indirect(¤t_head->object.oid); if (!tree) die(_("failed to unpack HEAD tree object")); - parse_tree(tree); + if (parse_tree(tree) < 0) + exit(128); init_tree_desc(&t, tree->buffer, tree->size); if (unpack_trees(1, &t, &opts)) exit(128); /* We've already reported the error, finish dying */ diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 2d4ce5b3886..3492a575a6c 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -447,12 +447,18 @@ static int real_merge(struct merge_tree_options *o, if (repo_get_oid_treeish(the_repository, merge_base, &base_oid)) die(_("could not parse as tree '%s'"), merge_base); base_tree = parse_tree_indirect(&base_oid); + if (!base_tree) + die(_("unable to read tree (%s)"), oid_to_hex(&base_oid)); if (repo_get_oid_treeish(the_repository, branch1, &head_oid)) die(_("could not parse as tree '%s'"), branch1); parent1_tree = parse_tree_indirect(&head_oid); + if (!parent1_tree) + die(_("unable to read tree (%s)"), oid_to_hex(&head_oid)); if (repo_get_oid_treeish(the_repository, branch2, &merge_oid)) die(_("could not parse as tree '%s'"), branch2); parent2_tree = parse_tree_indirect(&merge_oid); + if (!parent2_tree) + die(_("unable to read tree (%s)"), oid_to_hex(&merge_oid)); opt.ancestor = merge_base; merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result); diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 8196ca9dd85..5923ed36893 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -263,7 +263,8 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix) cache_tree_free(&the_index.cache_tree); for (i = 0; i < nr_trees; i++) { struct tree *tree = trees[i]; - parse_tree(tree); + if (parse_tree(tree) < 0) + return 128; init_tree_desc(t+i, tree->buffer, tree->size); } if (unpack_trees(nr_trees, t, &opts)) diff --git a/builtin/reset.c b/builtin/reset.c index 4b018d20e3b..fd36fc5bd95 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -119,6 +119,10 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t if (reset_type == MIXED || reset_type == HARD) { tree = parse_tree_indirect(oid); + if (!tree) { + error(_("unable to read tree (%s)"), oid_to_hex(oid)); + goto out; + } prime_cache_tree(the_repository, the_repository->index, tree); } diff --git a/cache-tree.c b/cache-tree.c index 641427ed410..c6508b64a5c 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -779,8 +779,8 @@ static void prime_cache_tree_rec(struct repository *r, struct cache_tree_sub *sub; struct tree *subtree = lookup_tree(r, &entry.oid); - if (!subtree->object.parsed) - parse_tree(subtree); + if (!subtree->object.parsed && parse_tree(subtree) < 0) + exit(128); sub = cache_tree_sub(it, entry.path); sub->cache_tree = cache_tree(); diff --git a/merge-ort.c b/merge-ort.c index 79d9e18f63d..910ba38ff05 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4983,6 +4983,9 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt, if (result->clean >= 0) { result->tree = parse_tree_indirect(&working_tree_oid); + if (!result->tree) + die(_("unable to read tree (%s)"), + oid_to_hex(&working_tree_oid)); /* existence of conflicted entries implies unclean */ result->clean &= strmap_empty(&opt->priv->conflicted); } diff --git a/merge-recursive.c b/merge-recursive.c index e3beb0801b1..10d41bfd487 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -410,7 +410,8 @@ static inline int merge_detect_rename(struct merge_options *opt) static void init_tree_desc_from_tree(struct tree_desc *desc, struct tree *tree) { - parse_tree(tree); + if (parse_tree(tree) < 0) + exit(128); init_tree_desc(desc, tree->buffer, tree->size); } diff --git a/merge.c b/merge.c index b60925459c2..14a7325859d 100644 --- a/merge.c +++ b/merge.c @@ -80,7 +80,10 @@ int checkout_fast_forward(struct repository *r, return -1; } for (i = 0; i < nr_trees; i++) { - parse_tree(trees[i]); + if (parse_tree(trees[i]) < 0) { + rollback_lock_file(&lock_file); + return -1; + } init_tree_desc(t+i, trees[i]->buffer, trees[i]->size); } diff --git a/reset.c b/reset.c index 48da0adf851..080bcb6d656 100644 --- a/reset.c +++ b/reset.c @@ -158,6 +158,11 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts) } tree = parse_tree_indirect(oid); + if (!tree) { + ret = error(_("unable to read tree (%s)"), oid_to_hex(oid)); + goto leave_reset_head; + } + prime_cache_tree(r, r->index, tree); if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0) { diff --git a/sequencer.c b/sequencer.c index d584cac8ed9..33d12b2ffd1 100644 --- a/sequencer.c +++ b/sequencer.c @@ -715,6 +715,8 @@ static int do_recursive_merge(struct repository *r, o.show_rename_progress = 1; head_tree = parse_tree_indirect(head); + if (!head_tree) + return error(_("unable to read tree (%s)"), oid_to_hex(head)); next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r); base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r); @@ -3887,6 +3889,8 @@ static int do_reset(struct repository *r, } tree = parse_tree_indirect(&oid); + if (!tree) + return error(_("unable to read tree (%s)"), oid_to_hex(&oid)); prime_cache_tree(r, r->index, tree); if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0) From patchwork Fri Feb 23 08:34:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568731 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0075E1B976 for ; Fri, 23 Feb 2024 08:34:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677275; cv=none; b=TmMRS+L8oKxtTueb0x5dKn44xH8IJTsZ28clXBjxz8FpIR6THmnw1ADk2CRD4bg5GYDLyYHedQFHvALRq5d+ZVVbedagvFUekIrKPwcMZAigdtDvG9WHBQdEB1Nv3NULED2TWTzCM2a4NkfLV0P2P+HtpNjyXXvx58uxPJ0AEi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677275; c=relaxed/simple; bh=QSb/Qh/k/jtO5PpkL3y6lTEdSq/J5NWkFsE0nmeVhaY=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=BjbOiZI/4PZVxxrgW9jfmyG2D7CFkJszZilmN5To/lkbm5M9NjOGGZpVHYEOmf5FQrQPbqKRPqrQ/TeB1Bie1Fq7hFlg1P/07LUXLuCS0DrKLBalaxPVdgR6p4YJE6676okBYHZjpxlko1DUu9lUGinckNTJBfYVSSdexrnNIYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hCrv0TZJ; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hCrv0TZJ" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-41296dce264so339075e9.3 for ; Fri, 23 Feb 2024 00:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677271; x=1709282071; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=y2HklqQzwQdN85hogz+D0Bk5KjHPdNYbw/bviEKo8cw=; b=hCrv0TZJt5+/2pWqKZy6Rl66j/TcSmGEIqTyAytHO8+EKrqxyIIVBMKNQ2gjUb8xN1 1vE6h1CIkaxzh7eIL9Dt2+dKwmQCQvFLXXaiUjE5zFCALkuepGoGxfEleCgOqxskkXe3 rWSIJL51+TAOidYk77VEzWZ2T5QMfRJVqGmRPev2githbFfXHkvjgV8AWipyRAS2K7rN 4W9xFfPDIqDPTl9u+lR3hu/wi/U2IMwvomd7FZsBusKJwUWCaWtGCAOM9p6fppkErUHR WqfzvbmOMfaKo+9ZsZGKyYz3NKjAvRElt+m0WtA9EfNGCO4TkLb0Im2dj0J5QsDau6lm hLvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677271; x=1709282071; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y2HklqQzwQdN85hogz+D0Bk5KjHPdNYbw/bviEKo8cw=; b=h9bc9Ij1yYENOqRiRS3yDneTBhJyrls3Q4MScLljnQP62Ol/fLJssb3xaRSHvDXYpu jqvySfZC/yWP0IQ/tePlAaXvmVKUo6tTh19OGP8j2dG9zC4UJY+UU88NHOtK7mTP2Ajk D7Qk/4ADq1HbgbbfJvPxzmfBj7ALmj36aqOb59m9ERiaGNi0KP/LCrawqjVYUo2eWtw1 Wcl37O/q+KCwF6nBXvMeb+R8GgH4Bkgi63sgu7aL+ohP/LhqGFYg3p1DtpGjoEoLMLfz lT39LoJ3cRD5PN02vI/9DYUv2h7L3nrlnNGhHtQ0/40u0baX8OXd4lvq8E1eb5wIP0h4 zwqg== X-Gm-Message-State: AOJu0YxoGtUc4+OLM7aQj47RUvdRRxVWZHGDjZSSl0oP95O24vupbw9m ciaF5TiPBwjM89334tZbegod6Gh9z4XbWZbRjBfPY2h88xdGasyQ5d2R7GK9 X-Google-Smtp-Source: AGHT+IGGVf+1KMnMv8hrgHdULWXq+IipQqbFh4eg4NrYr7KWam0Lge3NXZDRSB46HopoHYMT0h29Mw== X-Received: by 2002:a05:600c:4451:b0:40f:cf69:3e1a with SMTP id v17-20020a05600c445100b0040fcf693e1amr576866wmn.39.1708677271696; Fri, 23 Feb 2024 00:34:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k18-20020adff5d2000000b0033d4dab14a8sm1920478wrp.22.2024.02.23.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:31 -0800 (PST) Message-ID: <7e5e84a4e7c5733c7f229a7713713d44406ad573.1708677266.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:24 +0000 Subject: [PATCH v4 5/6] cache-tree: avoid an unnecessary check Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin The first thing the `parse_tree()` function does is to return early if the tree has already been parsed. Therefore we do not need to guard the `parse_tree()` call behind a check of that flag. As of time of writing, there are no other instances of this in Git's code bases: whenever the `parsed` flag guards a `parse_tree()` call, it guards more than just that call. Suggested-by: Patrick Steinhardt Signed-off-by: Johannes Schindelin --- cache-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache-tree.c b/cache-tree.c index c6508b64a5c..78d6ba92853 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -779,7 +779,7 @@ static void prime_cache_tree_rec(struct repository *r, struct cache_tree_sub *sub; struct tree *subtree = lookup_tree(r, &entry.oid); - if (!subtree->object.parsed && parse_tree(subtree) < 0) + if (parse_tree(subtree) < 0) exit(128); sub = cache_tree_sub(it, entry.path); sub->cache_tree = cache_tree(); From patchwork Fri Feb 23 08:34:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 13568733 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1534B3C486 for ; Fri, 23 Feb 2024 08:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677276; cv=none; b=ERaqF+WUE1cS5JhJ9juw/U6KizECeX+7xJurNNX63ESHN2dYpDpqNlRrogA1ft0Yr/QvqKWyH2BdnNDhz41pcVpyy1quddtpXo7ZJpCdf0/pA8SKJzzI9i5K2xAUtQhpM2tQkfb29KsvygoUW2YAkr5E+wdDLDFCmGxVquPpB9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708677276; c=relaxed/simple; bh=YCozWNngAqYBh7zCCfQZBsTj1IMTwlQDNRn1AjIZyko=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=NGBszkT9SGH29j8+uwQzYFv591po44UUGPO/2tgrNvqmADlHOti2nK8pptjTNLmzpSywJVFrenQM+cj+gDxbYBmN/+4JIwkTUyOMozAhLKSAr4P9ujUNbku2xnnp5lIpdBGnRpKOyLPU75y2IB23gBeU90HhLO3JApoxfseII6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nnu1w1Zh; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nnu1w1Zh" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4125e435b38so553435e9.0 for ; Fri, 23 Feb 2024 00:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708677273; x=1709282073; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=e0HM0YAvmR9I93PgyzmMqXUffXelA78jHKCiUec6Ybg=; b=nnu1w1ZhaZ8JMMPR67sWvos+JiO73NPGCp49smQBY7EKd0K2X84fOS4Gnn+xei3hhd G/xxE3zR4YRYU1J4bWovGCKumDq7BARsVJJOv7WqJEhfQBMG31fvX5hfW5lO+wU+2GeK X20U9ikuDznlCpbVTlvREGA4KvH087VYdVRN+ASSy3ej4T5VNjxsvXZWzqW8j6bbOOyp vfBMRtzlKVvyGcLD/pSuhJlEvUADrtySbsx0wsMQ/jQRX1/F+zsXqROyEV7XSDCtcZ4J imWBMf/Pu2p594IF1daaTtLDjNOkHaPXoTy73aeINRCCrW8NrQcJXSiLLbtng28F169e KPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677273; x=1709282073; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e0HM0YAvmR9I93PgyzmMqXUffXelA78jHKCiUec6Ybg=; b=aHkyUdoUMAwp8yWGR2UmTCC/VkZ22o6i5ufxQbhZOjyfoc40wEpaOJJWCISpw70lEI 2Y1q+Si7ifbMr038eSn7srvtO2OBhuqZLPFvgKH026n65zNUu1P7u1w3vRYjzcqYzsrq OixUpWD++RR/IWJT14PIDrM99UT0XFMqXCA/7qWVDdA27wOZES6gwQaNwk+DT6IW5x/f fwrLkoAVarckXM+kwtmRZwAgYHRBtH+J1bOogZ9HqX8yUxxRGTllUS3dO2AiEEXk1Lpu srvPtiGtKvSqzQ5Va5nznoiquftIJFeCw7LkOQjFDkvcTqIH5mkZWMg/rdBgvoicJtt2 CRSA== X-Gm-Message-State: AOJu0YxQcWdKXGalkoJGhjavwnMdL2HEBhwmroviwnTpc0JudmySs08+ +XZ1LjuG+dYjYJ1EmN3zeJf+enMLPOvkdxTtHybolN8TIye70Y4UXror0SO7 X-Google-Smtp-Source: AGHT+IGLEQlnUeQKt8e9+xhmF6GNUGnexQT3wL0nGcNeOkqOVPMgrHlTXJpA1vFzO5CEsN0koFFD3Q== X-Received: by 2002:adf:ed90:0:b0:33d:19fc:c4e9 with SMTP id c16-20020adfed90000000b0033d19fcc4e9mr794885wro.50.1708677272776; Fri, 23 Feb 2024 00:34:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y6-20020adfee06000000b0033ce727e728sm1889796wrn.94.2024.02.23.00.34.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 00:34:31 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 23 Feb 2024 08:34:25 +0000 Subject: [PATCH v4 6/6] fill_tree_descriptor(): mark error message for translation Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Patrick Steinhardt , Eric Sunshine , Johannes Schindelin , Johannes Schindelin From: Johannes Schindelin From: Johannes Schindelin There is an error message in that function to report a missing tree; In contrast to three other, similar error messages, it is not marked for translation yet. Mark it for translation, and while at it, make the error message consistent with the others by enclosing the SHA in parentheses. This requires a change to t6030 which expects the previous format of the commit message. Theoretically, this could present problems with existing scripts that use `git bisect` and parse its output (because Git does not provide other means for callers to discern between error conditions). However, this is unlikely to matter in practice because the most common course of action to deal with fatal corruptions is to report the error message to the user and exit, rather than trying to do something with the reported SHA of the missing tree. Signed-off-by: Johannes Schindelin --- t/t6030-bisect-porcelain.sh | 2 +- tree-walk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 2a5b7d8379c..58f3d9c675e 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -872,7 +872,7 @@ test_expect_success 'broken branch creation' ' echo "" > expected.ok cat > expected.missing-tree.default <