From patchwork Tue Oct 22 21:14:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kristoffer Haugsbakk X-Patchwork-Id: 13846166 Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89DC018DF6B for ; Tue, 22 Oct 2024 21:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729631685; cv=none; b=Ve0OU+u8RIJckulemZb4v5405IPcYiN1tkL5ijbbANm+cSqLcSuSEO+bY2CIIXrimiKlPgfCaSEdTt8EJScX8V7VnMmAdTjv0OpTf3WZrGge76gcbIdD4b7Vpa4qn/gwSAmZ48QvI4C95INiLFRzcLP27GA/A7p9Q5vSAfPotmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729631685; c=relaxed/simple; bh=JVU+E6hevko9479RnJpbXjJrhu4KPHhp3OxmOSiyv/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q85OA7g2FP+LXjepyOnteN9eY3Akf3RIj17SYHOaVkyzpbuGNWcF/D3HvX0CbsjgdQ2ZgLZmZQgClTxnjX0n3fw8h+abrW5eLbk6R0CdBL/HZYUJ6Hn40g9OPkPN47dE+/Ka4IlVuJfdF/Vvpr875Rj2M+2nOB1IwtPEPdY2S3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com; spf=pass smtp.mailfrom=fastmail.com; dkim=pass (2048-bit key) header.d=fastmail.com header.i=@fastmail.com header.b=swXiy1hW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Pc94yhVc; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fastmail.com header.i=@fastmail.com header.b="swXiy1hW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Pc94yhVc" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 89CD5114012D; Tue, 22 Oct 2024 17:14:42 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 22 Oct 2024 17:14:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1729631682; x=1729718082; bh=caN8fVzggnGCt9AEYeFUafltArNP0pu3hs6/hZQLkbE=; b= swXiy1hWZ0t4JHcVRF5Q//Un0zVeExayChTKf9jO4/p6MKIqt1fcoIVYVP7JFvd9 GYpmEIMbnBmUFGFDh5Z+LV27QeTt52Qaa5baETWmm+/XpwCtU5ii9a/s6Mb6cLNF 7Xo5ch6IkxRHvLHfGzW/9d3Vqe4ysy6jtea2GaGF/qvvk5CJGyiN5sHAUcMfvGah F0s+TtWqo54Shg1b0RizOgTw0AI5wbSmaptKt+3rWwUaI+vB61ytQMV6sVbvrEdg +pMXR4iap8ae6aC9bUNlJ6xmVbH/zC46pwPZqFoolPXjcM9IaKXSe1K8S60cn0uW 7Q9Aaf2AB2LhcRRUkCSB7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1729631682; x= 1729718082; bh=caN8fVzggnGCt9AEYeFUafltArNP0pu3hs6/hZQLkbE=; b=P c94yhVcBcEjlCXN6Uvu0mwFLTNijhYxKzj4MWrFb4gQjJAYes43Piq4yIZO3mWI7 +STu+U3kkaH01mfyVvQTkuRPiMy6zwPTImVbUDHpe2jgseVuPYz/nHZ7xArGROm0 eMf2Y1hOHpY3gM2/p90x6UwLA9AZ/axWbORtZkoPM+qMIz6CgQvt6Vc+0AyjEWvP 0ayRQsIMUI5oXCozRN3HmYvIBWmoVUrZO0Cg8ptimhIPxwLl/xjjuxHbmhcMBNiT oRIPb11q4/KcI665HZHDxQ79q2Z2ErQdWrSqISEHQj6Z18zOKAooLCgvKoVo0szn D7yRan40Us2Kkxs9wLDvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeihedgudehkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvve fufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpehkrhhishhtohhffhgvrhhh rghughhssggrkhhksehfrghsthhmrghilhdrtghomhenucggtffrrghtthgvrhhnpedule fgueeiueetkeelieefgedufeehteekhfejffekvdeuhedtvefhkeeikefhgfenucffohhm rghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhrihhsthhofhhfvghrhhgruhhgshgsrghkkhesfhgrshht mhgrihhlrdgtohhmpdhnsggprhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptgho uggvsehkhhgruhhgshgsrghkkhdrnhgrmhgvpdhrtghpthhtohepghhithhsthgvrhesph hosghogidrtghomhdprhgtphhtthhopegushhimhhitgesmhgrnhhjrghrohdrohhrghdp rhgtphhtthhopehmvgesthhtrgihlhhorhhrrdgtohhm X-ME-Proxy: Feedback-ID: i8b11424c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Oct 2024 17:14:40 -0400 (EDT) From: kristofferhaugsbakk@fastmail.com To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , gitster@pobox.com, dsimic@manjaro.org, me@ttaylorr.com Subject: [PATCH v3] t7001: add failure test which triggers assertion Date: Tue, 22 Oct 2024 23:14:33 +0200 Message-ID: X-Mailer: git-send-email 2.46.1.641.g54e7913fcb6 In-Reply-To: <29d71db280c972c91174bd0a501af66be72643af.1729462326.git.code@khaugsbakk.name> References: <29d71db280c972c91174bd0a501af66be72643af.1729462326.git.code@khaugsbakk.name> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Commit-Hash: c4ada0b787736ecd5aee986b1b8a4f90ccb84e21 X-Previous-Commits: 29d71db280c972c91174bd0a501af66be72643af From: Kristoffer Haugsbakk `git mv a/a.txt a b/` is a nonsense instruction. Instead of failing gracefully the command trips over itself,[1] leaving behind unfinished work: 1. first it moves `a/a.txt` to `b/a.txt`; then 2. tries to move `a/`, including `a/a.txt`; then 3. figures out that it’s in a bad state (assertion); and finally 4. aborts. Now you’re left with a partially-updated index. The command should instead fail gracefully and make no changes to the index until it knows that it can complete a sensible action. For now just add a failing test since this has been known about for a while.[2] † 1: Caused by a `pos >= 0` assertion [2]: https://lore.kernel.org/git/d1f739fe-b28e-451f-9e01-3d2e24a0fe0d@app.fastmail.com/ Helped-by: Junio C Hamano Signed-off-by: Kristoffer Haugsbakk --- Notes (series): v3: • Rewrite commit message based on Junio’s reply • Tweak test description: less volatile. Also mention index state. v1/v2: • It’s been a good while. Let’s just add this as a known breakage? Notes (meta-trailers): Helped-by: Junio C Hamano Comment: Commit message is based on his description Link: https://lore.kernel.org/git/xmqqil47obnw.fsf@gitster.g/ t/t7001-mv.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) Interdiff against v2: diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 739c25e255..69c9190772 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -551,7 +551,7 @@ test_expect_success 'moving nested submodules' ' git status ' -test_expect_failure 'nonsense mv triggers assertion failure at builtin/mv.c:502' ' +test_expect_failure 'nonsense mv triggers assertion failure and partially updated index' ' test_when_finished git reset --hard HEAD && git reset --hard HEAD && mkdir -p a && base-commit: 34b6ce9b30747131b6e781ff718a45328aa887d0 diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 86258f9f43..69c9190772 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -551,4 +551,16 @@ test_expect_success 'moving nested submodules' ' git status ' +test_expect_failure 'nonsense mv triggers assertion failure and partially updated index' ' + test_when_finished git reset --hard HEAD && + git reset --hard HEAD && + mkdir -p a && + mkdir -p b && + >a/a.txt && + git add a/a.txt && + test_must_fail git mv a/a.txt a b && + git status --porcelain >actual && + grep "^A[ ]*a/a.txt$" actual +' + test_done