@@ -1461,11 +1461,23 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
1461
1461
return maintenance_run_tasks (& opts );
1462
1462
}
1463
1463
1464
+ static char * get_maintpath (void )
1465
+ {
1466
+ struct strbuf sb = STRBUF_INIT ;
1467
+ const char * p = the_repository -> worktree ?
1468
+ the_repository -> worktree : the_repository -> gitdir ;
1469
+
1470
+ strbuf_realpath (& sb , p , 1 );
1471
+ return strbuf_detach (& sb , NULL );
1472
+ }
1473
+
1464
1474
static int maintenance_register (void )
1465
1475
{
1476
+ int rc ;
1466
1477
char * config_value ;
1467
1478
struct child_process config_set = CHILD_PROCESS_INIT ;
1468
1479
struct child_process config_get = CHILD_PROCESS_INIT ;
1480
+ char * maintpath = get_maintpath ();
1469
1481
1470
1482
/* Disable foreground maintenance */
1471
1483
git_config_set ("maintenance.auto" , "false" );
@@ -1478,40 +1490,44 @@ static int maintenance_register(void)
1478
1490
1479
1491
config_get .git_cmd = 1 ;
1480
1492
strvec_pushl (& config_get .args , "config" , "--global" , "--get" ,
1481
- "--fixed-value" , "maintenance.repo" ,
1482
- the_repository -> worktree ? the_repository -> worktree
1483
- : the_repository -> gitdir ,
1484
- NULL );
1493
+ "--fixed-value" , "maintenance.repo" , maintpath , NULL );
1485
1494
config_get .out = -1 ;
1486
1495
1487
- if (start_command (& config_get ))
1488
- return error (_ ("failed to run 'git config'" ));
1496
+ if (start_command (& config_get )) {
1497
+ rc = error (_ ("failed to run 'git config'" ));
1498
+ goto done ;
1499
+ }
1489
1500
1490
1501
/* We already have this value in our config! */
1491
- if (!finish_command (& config_get ))
1492
- return 0 ;
1502
+ if (!finish_command (& config_get )) {
1503
+ rc = 0 ;
1504
+ goto done ;
1505
+ }
1493
1506
1494
1507
config_set .git_cmd = 1 ;
1495
1508
strvec_pushl (& config_set .args , "config" , "--add" , "--global" , "maintenance.repo" ,
1496
- the_repository -> worktree ? the_repository -> worktree
1497
- : the_repository -> gitdir ,
1498
- NULL );
1509
+ maintpath , NULL );
1510
+
1511
+ rc = run_command ( & config_set );
1499
1512
1500
- return run_command (& config_set );
1513
+ done :
1514
+ free (maintpath );
1515
+ return rc ;
1501
1516
}
1502
1517
1503
1518
static int maintenance_unregister (void )
1504
1519
{
1520
+ int rc ;
1505
1521
struct child_process config_unset = CHILD_PROCESS_INIT ;
1522
+ char * maintpath = get_maintpath ();
1506
1523
1507
1524
config_unset .git_cmd = 1 ;
1508
1525
strvec_pushl (& config_unset .args , "config" , "--global" , "--unset" ,
1509
- "--fixed-value" , "maintenance.repo" ,
1510
- the_repository -> worktree ? the_repository -> worktree
1511
- : the_repository -> gitdir ,
1512
- NULL );
1526
+ "--fixed-value" , "maintenance.repo" , maintpath , NULL );
1513
1527
1514
- return run_command (& config_unset );
1528
+ rc = run_command (& config_unset );
1529
+ free (maintpath );
1530
+ return rc ;
1515
1531
}
1516
1532
1517
1533
static const char * get_frequency (enum schedule_priority schedule )
0 commit comments