From patchwork Sun Feb 25 18:24:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13571017 Received: from mout.web.de (mout.web.de [212.227.17.12]) (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 935F118AF9 for ; Sun, 25 Feb 2024 18:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708885490; cv=none; b=BNv7fpgOi3LP3K3M0YYLAyrDS0CbhW7XRKR45tbgOceX8g40EkeL1xVwduZatTDy+JAiu9YqZJo71BNrQGj88N9amqoqfMwTGQAfYeO9QtVl6YLbhGMBvm9weK5wOF5uOZ8e7FHoWbX05N4EsNMwETjaws/EO1xijnBMBaWjyJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708885490; c=relaxed/simple; bh=EVt3x/92a/lZBoPGP/zmEOqlAd2d2CzJuFGlNm7ez3Y=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=OcwFmZxeRcAyrp1cjlmgpsc+F18UKSqmHxMxZ92eOHnn7f1LyEbZNJnqZZkgwwXE8i6AJXItTBd4kqOr1golBLyBZEtLUlbNMhjCV2Ka9i4cxfqMvFGjTRNFl6FJdekK+9knn4fSGIAvnlhu/9eGCSWrDrQaBRE7x8VPnRYbhWM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=l.s.r@web.de header.b=uiIzgZ1U; arc=none smtp.client-ip=212.227.17.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=l.s.r@web.de header.b="uiIzgZ1U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1708885480; x=1709490280; i=l.s.r@web.de; bh=EVt3x/92a/lZBoPGP/zmEOqlAd2d2CzJuFGlNm7ez3Y=; h=X-UI-Sender-Class:Date:To:From:Subject; b=uiIzgZ1UD386rT2WjRpzuuTO/ParBz3pH9reZBhbqhyS9b+o3rgeuzLj5Q59P4MR TuZxh/GRIpBHbVmSDoctUIefATcDrAzXuL2VgjP2Dzgmdur33aN0b2etlnUX+u4fR aq1IJyEK0ZHNgTJZrvJB1q05jY0pH0kvUFMYmxShhu5kB6PTmgFDngBmdT0RSD9Vt c54/WJGcVYpByZqNZp64E6aqR4PpxMZyawLeX+vZnsXismtC3/cP0URmFf/46ATDA h5pppZN7mgVpqWFcq20F+kahw+wXnYR0a8Q0liABh1ipVFh5TeGovM0swP+TMSach 28szOeHhrYY9sjpicA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.19.211]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MSZHv-1rT90L08Px-00SnQw for ; Sun, 25 Feb 2024 19:24:40 +0100 Message-ID: <8cd983fb-32b9-41c6-a9e7-a485b190488c@web.de> Date: Sun, 25 Feb 2024 19:24:39 +0100 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Git List From: =?utf-8?q?Ren=C3=A9_Scharfe?= Subject: [PATCH] submodule: use strvec_pushf() for --submodule-prefix X-Provags-ID: V03:K1:2fHVHL6X+Tk7ih+XnlxAuJB09Uo0PBj3frs4XbGa/jJD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ODNFFnz7j7Q/Y/7rxaDqgr1r4gpZBi6Zv44M= Add the option --submodule-prefix and its argument directly using strvec_pushf() instead of via a detour through a strbuf. This is shorter, easier to read and doesn't require any explicit cleanup afterwards. Signed-off-by: René Scharfe --- submodule.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) -- 2.44.0 diff --git a/submodule.c b/submodule.c index 213da79f66..40f13a3685 100644 --- a/submodule.c +++ b/submodule.c @@ -1687,8 +1687,6 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, task = get_fetch_task_from_changed(spf, err); if (task) { - struct strbuf submodule_prefix = STRBUF_INIT; - child_process_init(cp); cp->dir = task->repo->gitdir; prepare_submodule_repo_env_in_gitdir(&cp->env); @@ -1698,15 +1696,11 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, strvec_pushv(&cp->args, task->git_args.v); strvec_pushv(&cp->args, spf->args.v); strvec_push(&cp->args, task->default_argv); - strvec_push(&cp->args, "--submodule-prefix"); + strvec_pushf(&cp->args, "--submodule-prefix=%s%s/", + spf->prefix, task->sub->path); - strbuf_addf(&submodule_prefix, "%s%s/", - spf->prefix, - task->sub->path); - strvec_push(&cp->args, submodule_prefix.buf); *task_cb = task; - strbuf_release(&submodule_prefix); string_list_insert(&spf->seen_submodule_names, task->sub->name); return 1; } @@ -1714,12 +1708,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, if (spf->oid_fetch_tasks_nr) { struct fetch_task *task = spf->oid_fetch_tasks[spf->oid_fetch_tasks_nr - 1]; - struct strbuf submodule_prefix = STRBUF_INIT; spf->oid_fetch_tasks_nr--; - strbuf_addf(&submodule_prefix, "%s%s/", - spf->prefix, task->sub->path); - child_process_init(cp); prepare_submodule_repo_env_in_gitdir(&cp->env); cp->git_cmd = 1; @@ -1728,8 +1718,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, strvec_init(&cp->args); strvec_pushv(&cp->args, spf->args.v); strvec_push(&cp->args, "on-demand"); - strvec_push(&cp->args, "--submodule-prefix"); - strvec_push(&cp->args, submodule_prefix.buf); + strvec_pushf(&cp->args, "--submodule-prefix=%s%s/", + spf->prefix, task->sub->path); /* NEEDSWORK: have get_default_remote from submodule--helper */ strvec_push(&cp->args, "origin"); @@ -1737,7 +1727,6 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, append_oid_to_argv, &cp->args); *task_cb = task; - strbuf_release(&submodule_prefix); return 1; }