Subject: Re: git maintenance broken on FreeBSD

From: Đoàn Trần Công Danh <[email-masked]>
Date: Fri, 12 Aug 2022 21:44:16 +0700

On 2022-08-12 10:51:03-0300, Renato Botelho <[email-masked]> wrote:
> As reported at [1], git maintenance is not working on FreeBSD.  I didn't
> find the time to dig into it but it seems like it's calling crontab using
> parameters not supported on FreeBSD.
> 
> [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260746

It seems like FreeBSD's cron is vixie-cron which requires <file>
passed to crontab(1).

     The crontab command conforms to IEEE Std 1003.2 (“POSIX.2”) with the
     exception that the dangerous variant of calling crontab without a file
     name in the first form of the command is not allowed by this
     implementation.  The pseudo-filename ‘-’ must be specified to read from
     standard input.  The new command syntax differs from previous versions of
     Vixie Cron, as well as from the classic SVR3 syntax.

I think other crontab implementation also accept "-" as filename for stdin.
At least cronie, fcron, dcron, and busybox's crontab both supports "-" as stdin.

I think this patch can fix FreeBSD's problem:

---- 8< -----
diff --git a/builtin/gc.c b/builtin/gc.c
index eeff2b760e..45d908def3 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -2087,6 +2087,7 @@ static int crontab_update_schedule(int run_maintenance, int fd)
 	rewind(cron_list);
 
 	strvec_split(&crontab_edit.args, cmd);
+	strvec_push(&crontab_edit.args, "-");
 	crontab_edit.in = -1;
 	crontab_edit.git_cmd = 0;
 
---- 8< ---------

-- 
Danh