From patchwork Tue Jun 4 12:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13685184 Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (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 BA41614659B for ; Tue, 4 Jun 2024 12:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504703; cv=none; b=iKXBNJOhtUpJrgURzxF01lM2VDhAsWAUTTnP0NG2Rjp/rznZmgYAet+wyGbhpiu2NyR6XEjFpT3T+CqmI/MZ/DwQnHndapdmw1UWthvlU/kssUtrKvHvVANa3hyENBV0bqZF6lPpUiXcc3+Ut3Evu7ZfI3DZyxO1bIotaieUSqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504703; c=relaxed/simple; bh=EBKM4s7WiC6Zf/Pg3SUa8z8Uz3mp0d1E490oFO/PAkI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=igZpzhB4oTQweem66Br4PtwtfGQ88mMmAEM8KmlAYS/s1FGV5xAMGH9DK2NherhRkbXldx6/lMCnfia9C7Uqm5iOYRSp1xwLbOP6lDPi21NUntQSBt5DaIY+OsyxKq4aL2x3w26N8tNReIlMDMBUXKpsFxjwRP4yifX4mp8r7SY= 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=KWbWN9J8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=CiZzY4fe; arc=none smtp.client-ip=103.168.172.144 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="KWbWN9J8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="CiZzY4fe" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 19572138015A; Tue, 4 Jun 2024 08:38:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 04 Jun 2024 08:38: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=1717504701; x=1717591101; bh=/6Vn63Rvo8 Lztbm5AW+kX+ECQGVatHGB3jpWJbcfu7A=; b=KWbWN9J8OtWiPPg9udYjZqMMiG /LxDn9Yxaf0wI5PyJawwme8Ph76ePzPB1CRKlgKYCRrYOf45JbxGzLA1TrQKib+D 9kWASJTAkbkUl+5K/oH1BgnKduR0WeHXrT1BXjMFmuWPfojZfAtOarJVkWrXK2rf DdiDaUofeAkclmQdKbSR5PSWpnFyxj6lcpgMERGkYfp8OXO/WHsYhsbUEvCip4hR ft+7PCjUYmmJkB+/l6IteFyXfaSrzzSOdivxe3f6LcAjBzF65JyAnjdart0wbZgy g6ZAbHGXEMjvlr6X4esvGx9E0B0Fcw1VXhPHaN8ljoBIpelGjwRRXTdLLgew== 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=1717504701; x=1717591101; bh=/6Vn63Rvo8Lztbm5AW+kX+ECQGVa tHGB3jpWJbcfu7A=; b=CiZzY4feJqz/bo9ivJFDj4X5s8zSV7OlqizbSI9T2HXj GRi8qwp8/4PbTJ3KsSv+57PAIrpg64uDLbJ7jthBIqIt4LsD7PTNhQVIxKxK3TGr R1JGYV+doOMcbGAn0s8JDGdmB6Uz5RjyU2ffhA38tnYrQ1hjPhtkG2PbiA8iiqvK bcsPPNT5OgRRE3pVOekIRdywyHPtdBWLJIATh/fwhnRS3PL7KJ73A/uqxC1JTrMI DnqaHDdhb+BHlk+DoMWfoxN43Yf3QkrlTKhvwgxS5UoI87RBkkw6g7AuFtnwnA/o BQ42++qLw51nLmT19SlWEcN56+sPIuGZN2kE6sX3WQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelgedgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 08:38:19 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 780812a0 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 4 Jun 2024 12:37:52 +0000 (UTC) Date: Tue, 4 Jun 2024 14:38:17 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v4 18/27] send-pack: always allocate receive status Message-ID: <4019b532f96536f57161ce90f75c5958939b29ce.1717504517.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);