@@ -1309,8 +1309,6 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts)
13091309 char * lock_path = xstrfmt ("%s/maintenance" , r -> objects -> odb -> path );
13101310
13111311 if (hold_lock_file_for_update (& lk , lock_path , LOCK_NO_DEREF ) < 0 ) {
1312- struct stat st ;
1313- struct strbuf lock_dot_lock = STRBUF_INIT ;
13141312 /*
13151313 * Another maintenance command is running.
13161314 *
@@ -1321,25 +1319,6 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts)
13211319 if (!opts -> auto_flag && !opts -> quiet )
13221320 warning (_ ("lock file '%s' exists, skipping maintenance" ),
13231321 lock_path );
1324-
1325- /*
1326- * Check timestamp on .lock file to see if we should
1327- * delete it to recover from a fail state.
1328- */
1329- strbuf_addstr (& lock_dot_lock , lock_path );
1330- strbuf_addstr (& lock_dot_lock , ".lock" );
1331- if (lstat (lock_dot_lock .buf , & st ))
1332- warning_errno (_ ("unable to stat '%s'" ), lock_dot_lock .buf );
1333- else {
1334- if (st .st_mtime < time (NULL ) - (6 * 60 * 60 )) {
1335- if (unlink (lock_dot_lock .buf ))
1336- warning_errno (_ ("unable to delete stale lock file" ));
1337- else
1338- warning (_ ("deleted stale lock file" ));
1339- }
1340- }
1341-
1342- strbuf_release (& lock_dot_lock );
13431322 free (lock_path );
13441323 return 0 ;
13451324 }
@@ -1678,6 +1657,42 @@ static const char *get_frequency(enum schedule_priority schedule)
16781657 }
16791658}
16801659
1660+ static const char * extraconfig [] = {
1661+ "credential.interactive=false" ,
1662+ "core.askPass=true" , /* 'true' returns success, but no output. */
1663+ NULL
1664+ };
1665+
1666+ static const char * get_extra_config_parameters (void ) {
1667+ static const char * result = NULL ;
1668+ struct strbuf builder = STRBUF_INIT ;
1669+
1670+ if (result )
1671+ return result ;
1672+
1673+ for (const char * * s = extraconfig ; s && * s ; s ++ )
1674+ strbuf_addf (& builder , "-c %s " , * s );
1675+
1676+ result = strbuf_detach (& builder , NULL );
1677+ return result ;
1678+ }
1679+
1680+ static const char * get_extra_launchctl_strings (void ) {
1681+ static const char * result = NULL ;
1682+ struct strbuf builder = STRBUF_INIT ;
1683+
1684+ if (result )
1685+ return result ;
1686+
1687+ for (const char * * s = extraconfig ; s && * s ; s ++ ) {
1688+ strbuf_addstr (& builder , "<string>-c</string>\n" );
1689+ strbuf_addf (& builder , "<string>%s</string>\n" , * s );
1690+ }
1691+
1692+ result = strbuf_detach (& builder , NULL );
1693+ return result ;
1694+ }
1695+
16811696/*
16821697 * get_schedule_cmd` reads the GIT_TEST_MAINT_SCHEDULER environment variable
16831698 * to mock the schedulers that `git maintenance start` rely on.
@@ -1884,6 +1899,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
18841899 "<array>\n"
18851900 "<string>%s/git</string>\n"
18861901 "<string>--exec-path=%s</string>\n"
1902+ "%s" /* For extra config parameters. */
18871903 "<string>for-each-repo</string>\n"
18881904 "<string>--config=maintenance.repo</string>\n"
18891905 "<string>maintenance</string>\n"
@@ -1892,7 +1908,8 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit
18921908 "</array>\n"
18931909 "<key>StartCalendarInterval</key>\n"
18941910 "<array>\n" ;
1895- strbuf_addf (& plist , preamble , name , exec_path , exec_path , frequency );
1911+ strbuf_addf (& plist , preamble , name , exec_path , exec_path ,
1912+ get_extra_launchctl_strings (), frequency );
18961913
18971914 switch (schedule ) {
18981915 case SCHEDULE_HOURLY :
@@ -2127,11 +2144,12 @@ static int schtasks_schedule_task(const char *exec_path, enum schedule_priority
21272144 "<Actions Context=\"Author\">\n"
21282145 "<Exec>\n"
21292146 "<Command>\"%s\\headless-git.exe\"</Command>\n"
2130- "<Arguments>--exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
2147+ "<Arguments>--exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%s</Arguments>\n"
21312148 "</Exec>\n"
21322149 "</Actions>\n"
21332150 "</Task>\n" ;
2134- fprintf (tfile -> fp , xml , exec_path , exec_path , frequency );
2151+ fprintf (tfile -> fp , xml , exec_path , exec_path ,
2152+ get_extra_config_parameters (), frequency );
21352153 strvec_split (& child .args , cmd );
21362154 strvec_pushl (& child .args , "/create" , "/tn" , name , "/f" , "/xml" ,
21372155 get_tempfile_path (tfile ), NULL );
@@ -2272,8 +2290,8 @@ static int crontab_update_schedule(int run_maintenance, int fd)
22722290 "# replaced in the future by a Git command.\n\n" );
22732291
22742292 strbuf_addf (& line_format ,
2275- "%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n" ,
2276- exec_path , exec_path );
2293+ "%%d %%s * * %%s \"%s/git\" --exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%%s\n" ,
2294+ exec_path , exec_path , get_extra_config_parameters () );
22772295 fprintf (cron_in , line_format .buf , minute , "1-23" , "*" , "hourly" );
22782296 fprintf (cron_in , line_format .buf , minute , "0" , "1-6" , "daily" );
22792297 fprintf (cron_in , line_format .buf , minute , "0" , "0" , "weekly" );
@@ -2473,7 +2491,7 @@ static int systemd_timer_write_service_template(const char *exec_path)
24732491 "\n"
24742492 "[Service]\n"
24752493 "Type=oneshot\n"
2476- "ExecStart=\"%s/git\" --exec-path=\"%s\" for-each-repo --config=maintenance.repo maintenance run --schedule=%%i\n"
2494+ "ExecStart=\"%s/git\" --exec-path=\"%s\" %s for-each-repo --config=maintenance.repo maintenance run --schedule=%%i\n"
24772495 "LockPersonality=yes\n"
24782496 "MemoryDenyWriteExecute=yes\n"
24792497 "NoNewPrivileges=yes\n"
@@ -2483,7 +2501,7 @@ static int systemd_timer_write_service_template(const char *exec_path)
24832501 "RestrictSUIDSGID=yes\n"
24842502 "SystemCallArchitectures=native\n"
24852503 "SystemCallFilter=@system-service\n" ;
2486- if (fprintf (file , unit , exec_path , exec_path ) < 0 ) {
2504+ if (fprintf (file , unit , exec_path , exec_path , get_extra_config_parameters () ) < 0 ) {
24872505 error (_ ("failed to write to '%s'" ), filename );
24882506 fclose (file );
24892507 goto error ;
0 commit comments