From nobody Mon Aug 29 10:49:39 2022 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MGRyr1FgPz4ZrNc; Mon, 29 Aug 2022 10:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MGRyr0pJHz3x3Q; Mon, 29 Aug 2022 10:49:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661770180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o8KQWGV4P9m/YCezOaGp5EVMSi1m2CGb+qTMvpDsue0=; b=P/pAPfSIkBnViT3bJOAafs9hKTeh5aDDFiNp8x6VrbdwISwI4Yfu99QhTmh7Qq0rp/y85n u2PvZd/F8JRZy3qwOVA7+L5LnFX0lxc4w5SSNf6j0Qb1C17ZmchIhUYrSrYouRe6bAoQbB 6km3L72TGxd6c7NQ8JfnzESzcLLlkjCbIcs8PZ7CmK1NzKOdHFvlqh5KJa8jyiZDtmuspY w9q0rjHXS9dwGOp0abZKeq2RYX7//A0veFYAOUYn6txksxlKFDSSvDTwCfE4+BzAjfg+pA l9Mb+b4/Nse+THiWITyAqtpWmrZlnJVTbPtX/csyADuYUdSlIh6AdxfDc2a3Zw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MGRyq6xcgzPWQ; Mon, 29 Aug 2022 10:49:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27TAndDH040435; Mon, 29 Aug 2022 10:49:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27TAndNf040434; Mon, 29 Aug 2022 10:49:39 GMT (envelope-from git) Date: Mon, 29 Aug 2022 10:49:39 GMT Message-Id: <202208291049.27TAndNf040434@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Renato Botelho Subject: git: 82c314474fce - main - devel/git: Fix 'git maintenance start' List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: garga X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 82c314474fce8cd4a9ea5cc95d0ca4f6165e6acc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661770180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o8KQWGV4P9m/YCezOaGp5EVMSi1m2CGb+qTMvpDsue0=; b=bEIf39+QKNF/tQn6IExeIe7berGzxI5v3elFVSPbWFDso+wlvuqe21Gi/Y1YnX+kVgLx+P RN4VlHCD4cFJe2pIwf5BvipWjOxC5XYkiCIWvLl9qbX+ygB4DODEPaEfmD+kCxEIfuwW0P YHcSLzJRVMC4zY1FWRhArEZOtCr0ENAVeUxUbBwGi2TMP2iQy2KO6WzvZRBGPNQKtdQ5Bo iNXxkNYIcvQuzGN7gDfylnHgQFTzJIp81OCqWwIc9/wJhed6hY0UOOcseOfw9mdk73qjCD 5ADWX7bubM3MBgpmBtosBtdPPQrrekQ21YnbZ3znbP5b7ojTW569VqHZh4brEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661770180; a=rsa-sha256; cv=none; b=dN8SOnWM/SAAnDZPd3iODf3Pr40uCq/RMk+0qsrJQP80PHeZiKlHRcbbACqpuvwyMwPqBn MRGov/KaCTiIWqP6PgrFx51vAzTCOnQsTv7NzLNUOgO7hFF6tA2lImg9aawliixG1+XlD7 4cvs15jZgu4Bew4vusx0eolPTvKBM3BJRTcSzjUsGLMiIJsVWZhXQ9cHZVtiAMyOZ81KqJ vFWhz1fuAchG8sRktj+TlJmjfC2RTpGqMvNms2mjGKynAhVL0wPE1aEzpUQd/+zPnNGGe4 XM83zb4WY6XvH4mOGUyORFR7JeAMPvqoKvfh1L7bP6211PQ+22ztNvpq2tz7Qg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by garga: URL: https://cgit.FreeBSD.org/ports/commit/?id=82c314474fce8cd4a9ea5cc95d0ca4f6165e6acc commit 82c314474fce8cd4a9ea5cc95d0ca4f6165e6acc Author: Renato Botelho AuthorDate: 2022-08-29 10:15:42 +0000 Commit: Renato Botelho CommitDate: 2022-08-29 10:49:23 +0000 devel/git: Fix 'git maintenance start' Add a patch from upstream to fix 'git maintenance start'. Here follow upstream commit message: While cron is specified by POSIX, there are a wide variety of implementations in use. On FreeBSD, the cron implementation requires a file name argument: if the user wants to edit standard input, they must specify "-". However, this notation is not specified by POSIX, allowing the possibility that making such a change may break other, less common implementations. Since POSIX tells us that cron must accept a file name argument, let's solve this problem by specifying a temporary file instead. This will ensure that we work with the vast majority of implementations. Note that because delete_tempfile closes the file for us, we should not call fclose here on the handle, since doing so will introduce a double free. PR: 260746 Reported by: Mark Waite Obtained from: https://lore.kernel.org/git/1dd29f43-1a8e-eb69-3320-7f5140a0e18e@github.com/T/#me47087c1f9034c82da8eae83db18cc6114c2c1e5 Sponsored by: Rubicon Communications, LLC ("Netgate") --- devel/git/Makefile | 1 + devel/git/files/patch-fix-maintenance.diff | 112 +++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/devel/git/Makefile b/devel/git/Makefile index b67a43ae469b..19b313cbc33c 100644 --- a/devel/git/Makefile +++ b/devel/git/Makefile @@ -1,5 +1,6 @@ PORTNAME= git DISTVERSION= 2.37.2 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= KERNEL_ORG/software/scm/git DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ diff --git a/devel/git/files/patch-fix-maintenance.diff b/devel/git/files/patch-fix-maintenance.diff new file mode 100644 index 000000000000..c1ac6dec2452 --- /dev/null +++ b/devel/git/files/patch-fix-maintenance.diff @@ -0,0 +1,112 @@ +[PATCH v2] gc: use temporary file for editing crontab + +While cron is specified by POSIX, there are a wide variety of +implementations in use. On FreeBSD, the cron implementation requires a +file name argument: if the user wants to edit standard input, they must +specify "-". However, this notation is not specified by POSIX, allowing +the possibility that making such a change may break other, less common +implementations. + +Since POSIX tells us that cron must accept a file name argument, let's +solve this problem by specifying a temporary file instead. This will +ensure that we work with the vast majority of implementations. + +Note that because delete_tempfile closes the file for us, we should not +call fclose here on the handle, since doing so will introduce a double +free. + +Reported-by: Renato Botelho +Signed-off-by: brian m. carlson + +diff --git builtin/gc.c builtin/gc.c +index eeff2b760e..0d9e6dabef 100644 +--- builtin/gc.c ++++ builtin/gc.c +@@ -2065,6 +2065,7 @@ static int crontab_update_schedule(int run_maintenance, int fd) + struct child_process crontab_edit = CHILD_PROCESS_INIT; + FILE *cron_list, *cron_in; + struct strbuf line = STRBUF_INIT; ++ struct tempfile *tmpedit = NULL; + + get_schedule_cmd(&cmd, NULL); + strvec_split(&crontab_list.args, cmd); +@@ -2079,6 +2080,17 @@ static int crontab_update_schedule(int run_maintenance, int fd) + /* Ignore exit code, as an empty crontab will return error. */ + finish_command(&crontab_list); + ++ tmpedit = mks_tempfile_t(".git_cron_edit_tmpXXXXXX"); ++ if (!tmpedit) { ++ result = error(_("failed to create crontab temporary file")); ++ goto out; ++ } ++ cron_in = fdopen_tempfile(tmpedit, "w"); ++ if (!cron_in) { ++ result = error(_("failed to open temporary file")); ++ goto out; ++ } ++ + /* + * Read from the .lock file, filtering out the old + * schedule while appending the new schedule. +@@ -2086,19 +2098,6 @@ static int crontab_update_schedule(int run_maintenance, int fd) + cron_list = fdopen(fd, "r"); + rewind(cron_list); + +- strvec_split(&crontab_edit.args, cmd); +- crontab_edit.in = -1; +- crontab_edit.git_cmd = 0; +- +- if (start_command(&crontab_edit)) +- return error(_("failed to run 'crontab'; your system might not support 'cron'")); +- +- cron_in = fdopen(crontab_edit.in, "w"); +- if (!cron_in) { +- result = error(_("failed to open stdin of 'crontab'")); +- goto done_editing; +- } +- + while (!strbuf_getline_lf(&line, cron_list)) { + if (!in_old_region && !strcmp(line.buf, BEGIN_LINE)) + in_old_region = 1; +@@ -2132,14 +2131,22 @@ static int crontab_update_schedule(int run_maintenance, int fd) + } + + fflush(cron_in); +- fclose(cron_in); +- close(crontab_edit.in); + +-done_editing: ++ strvec_split(&crontab_edit.args, cmd); ++ strvec_push(&crontab_edit.args, get_tempfile_path(tmpedit)); ++ crontab_edit.git_cmd = 0; ++ ++ if (start_command(&crontab_edit)) { ++ result = error(_("failed to run 'crontab'; your system might not support 'cron'")); ++ goto out; ++ } ++ + if (finish_command(&crontab_edit)) + result = error(_("'crontab' died")); + else + fclose(cron_list); ++out: ++ delete_tempfile(&tmpedit); + return result; + } + +diff --git t/helper/test-crontab.c t/helper/test-crontab.c +index e7c0137a47..2942543046 100644 +--- t/helper/test-crontab.c ++++ t/helper/test-crontab.c +@@ -17,8 +17,8 @@ int cmd__crontab(int argc, const char **argv) + if (!from) + return 0; + to = stdout; +- } else if (argc == 2) { +- from = stdin; ++ } else if (argc == 3) { ++ from = fopen(argv[2], "r"); + to = fopen(argv[1], "w"); + } else + return error("unknown arguments"); +