From patchwork Thu May 30 12:51:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13680367 Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (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 41BA217F4FC for ; Thu, 30 May 2024 12:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073483; cv=none; b=BbbiS0Mk+65F+UXRQCA+9cULUaa7AnbAQmsa3CxN9K2nBibqS8pR/8Z+T/ZdZbntyMfK3jWW1E+KNVncGRyWkAFSs6zYYBMgNJOwS9fGFx2/wWAONQsGaVrPR5Scv45AIm044Svs5p9BIgaG0rF9tFGpJd2FsmLqqRKnYtUOg7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073483; c=relaxed/simple; bh=DZrcfUqJSheDrhj5ActQRzM+Qjuv0RmAYS6wjEVBM88=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GdDt8KUKvIZMJHP7Bpsq/XvwZbaYkCBx/4NGTJE/Fu5d4MUXK2s/JFgMg3FTlSNRlANbQthsLdvzWF5h2j5Bfs4mGwUpWKhl8FLMXDqQJAg5oUyN2nHxBfgfndmsnZVRgx5Il4uuVA79lMoDkFWb7VHbndi9HMLmAki1TltbV+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=XDQyXAak; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eJBYWJoA; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="XDQyXAak"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eJBYWJoA" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 65ADD1140155; Thu, 30 May 2024 08:51:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 30 May 2024 08:51:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :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=fm1; t=1717073481; x=1717159881; bh=bt2Z2vX5di 0hb/f9bDaPnJujrm1IXMrejzyTkHmw5lM=; b=XDQyXAak9aPKmEgRo9oqGKM5HG MPE/CQybm1SvKQ63l+K+iU7oDGjXdmuEiDxHVo2YYiZm25YguChbqhOHNz/KFCaw xLgL+ebIC6LdUaoAy1gLQ2sTmyJkTLJDz2qN1ioNgjLH5HIgquacbSUsycx+fym0 tcjVOU4iXgCI+CMK0bLPokwpMOphPzs5DzMRR5PUPq8GVLpTUd+BHRiy5U7shvPC mQVJ4wZElSzi9SEUPca9v3rVtaH66UlTbC/xWFfVnWFo82tyN09u4xDzOVINWQkY FxlwUK9u6faTUVTo170ohqX2DtiAYGVCqjVZTr4R7W8QIHWXuA/qIPCImSfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= fm1; t=1717073481; x=1717159881; bh=bt2Z2vX5di0hb/f9bDaPnJujrm1I XMrejzyTkHmw5lM=; b=eJBYWJoAkfv02yHow0I5rfwFxWVHW4qFb09+q9IuRnq1 bkQL5/ba6f1NwpW/Qcth6ZB24fQtE+H0dxl2syNw/Twpjw7sNz1EDIO/GxXEHiQB ntIAX6NLGYu6N858zXbn6Uqb77N32m1GiOckg+wSv+GRqzC/vvoepclsAOSB3zEd l/5KFXYaQwBdjnoqD6EqsVHymcyxRBBb1nG1Ns1zGN4Exro3zDGQBVXoFHqY199b clqLgY1ktawwNTTndmFQtqIbLobUg0upnZ6pHryP8SP96GUFXLm/pYHbMDiT4CcT OZT4FcvTyt4LIqOeTojuq7g9tiuitlQmYdifP/TlUQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekgedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpeefnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 May 2024 08:51:20 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id b327cbef (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 30 May 2024 12:51:04 +0000 (UTC) Date: Thu, 30 May 2024 14:51:18 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v2 10/19] send-pack: always allocate receive status Message-ID: <462502127d8bdfc77f9e4b8ba975f41fb12b3476.1717073346.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In `receive_status()`, we record the reason why ref updates have been rejected by the remote via the `remote_status`. But while we allocate the assigned string when a reason was given, we assign a string constant when no reason was given. This has been working fine so far due to two reasons: - We don't ever free the refs in git-send-pack(1)' - Remotes always give a reason, at least as implemented by Git proper. Adapt the code to always allocate the receive status string and free the refs. Signed-off-by: Patrick Steinhardt --- builtin/send-pack.c | 2 ++ send-pack.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/send-pack.c b/builtin/send-pack.c index 3df9eaad09..17cae6bbbd 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -336,5 +336,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix) /* stable plumbing output; do not modify or localize */ fprintf(stderr, "Everything up-to-date\n"); + free_refs(remote_refs); + free_refs(local_refs); return ret; } diff --git a/send-pack.c b/send-pack.c index 37f59d4f66..88e96d000b 100644 --- a/send-pack.c +++ b/send-pack.c @@ -259,7 +259,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs) if (p) hint->remote_status = xstrdup(p); else - hint->remote_status = "failed"; + hint->remote_status = xstrdup("failed"); } else { hint->status = REF_STATUS_OK; hint->remote_status = xstrdup_or_null(p);