From patchwork Mon Jun 3 09:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13683487 Received: from wfhigh7-smtp.messagingengine.com (wfhigh7-smtp.messagingengine.com [64.147.123.158]) (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 59A6485279 for ; Mon, 3 Jun 2024 09:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407628; cv=none; b=T/8mLoQaLoBXmZRbRfgYe7rySTCkvTRja7SVfuYnzIz4gsCNJpZDkp7o3kRJDzOmxSfLSf24mAIZyvMyUmmchdryqHZAukBUa8YxHhpiW5hZS/9Pv4pKB6Np7FOaRZAtmvzpDWlsNj+e3u+1cFI5VqPMebSpHxtJ5dM/VlF8S0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407628; c=relaxed/simple; bh=1vJRZtDDeIuGD6SlTWliu5ouCcas3f7gL6VD80fyYKw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R+OtNg3GZRnKWWgZAD35hFcIarSMfXbqT+1CwJBfwI+T0uAXVF3wRulS6DIF1kNgRvRwypPvWBCY/YH3ycSwD4+JonWyD0I2ecAPnDseOy/LW4xT8twEATOW1CQN8e0ZOjvbWYeTIGHJgCKfXWIAxZWYvS1RrRKW5gcVRb3LS7k= 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=gsTt3tef; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=pReCktC6; arc=none smtp.client-ip=64.147.123.158 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="gsTt3tef"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="pReCktC6" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id 84BFA180009D; Mon, 3 Jun 2024 05:40:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 03 Jun 2024 05:40:26 -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=1717407626; x=1717494026; bh=IzbmM1IHqI XjxyIo0vqc+WSTwuRTplPh0C3J6Fx6CPA=; b=gsTt3tef4euCkM6H1hT+SFnOI2 IOKUCjkhy9+CjviqiMky4XhWAOVqt4NJCkJleoZ+yYH/DW7hGxGGTLBEk5MXbiOF KpRRrBKW8BCREvYtjPZq0jjyAKI+elReIVNC79yj5+yqIv0t4G/TfrOFRpHurd9Q xYAbKxN8cmQQZ8yNSSdrVPC+1yOIgVZ7atvLxziPrWaCLBW5AdlFRcipPmGhFUJS TAWroenXVF+eoDoUGezxquTNhgWFfdKFXLsKeEgQhxRosDcRVNARcX0t3aVWeQpj xZcWjuaW48bdjhb4tsSSBhjOd9RhZ1eEaUKJ+DzigPJGCMmaJdyamt1DrSHQ== 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=1717407626; x=1717494026; bh=IzbmM1IHqIXjxyIo0vqc+WSTwuRT plPh0C3J6Fx6CPA=; b=pReCktC6QGnUgaH04lxUCyZ/9nvLGLZfWZcxKZIj10/x /y/+LGnyCzAHqA719TbekMWu0PTiz0BYu0XYbkEgHa7aKk/6f4tek+euGR/CAb3N wDsgDaFdstS0d26hLLuLl0nV/DEkFEHo57iv6FwRYwk8It7sF/r1FWWBcxJj/NUX 9DcnUh5rYIz7y50N7O/W4XDXhYg3aKkKD1+GA0hYfToA1mqwY+hpW+ovFDj3QF2o hnsVmot+Yqdw55n8E0YLhGVToe40gLPY/GSH5FnkUvWTMeN4kil+eJL7ioP4wm5R 0b+RAqXHfyhFVl9reGocHb2PJG5/hnH0BRHY47invQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpeegnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 05:40:25 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 16b60205 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Jun 2024 09:40:00 +0000 (UTC) Date: Mon, 3 Jun 2024 11:40:22 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v3 18/27] send-pack: always allocate receive status Message-ID: 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);