@@ -33,11 +33,13 @@ static int gc_auto_threshold = 6700;
33
33
static int gc_auto_pack_limit = 50 ;
34
34
static int detach_auto = 1 ;
35
35
static const char * prune_expire = "2.weeks.ago" ;
36
+ static const char * prune_worktrees_expire = "3.months.ago" ;
36
37
37
38
static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT ;
38
39
static struct argv_array reflog = ARGV_ARRAY_INIT ;
39
40
static struct argv_array repack = ARGV_ARRAY_INIT ;
40
41
static struct argv_array prune = ARGV_ARRAY_INIT ;
42
+ static struct argv_array prune_worktrees = ARGV_ARRAY_INIT ;
41
43
static struct argv_array rerere = ARGV_ARRAY_INIT ;
42
44
43
45
static char * pidfile ;
@@ -83,6 +85,7 @@ static void gc_config(void)
83
85
git_config_get_int ("gc.autopacklimit" , & gc_auto_pack_limit );
84
86
git_config_get_bool ("gc.autodetach" , & detach_auto );
85
87
git_config_date_string ("gc.pruneexpire" , & prune_expire );
88
+ git_config_date_string ("gc.pruneworktreesexpire" , & prune_worktrees_expire );
86
89
git_config (git_default_config , NULL );
87
90
}
88
91
@@ -290,6 +293,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
290
293
argv_array_pushl (& reflog , "reflog" , "expire" , "--all" , NULL );
291
294
argv_array_pushl (& repack , "repack" , "-d" , "-l" , NULL );
292
295
argv_array_pushl (& prune , "prune" , "--expire" , NULL );
296
+ argv_array_pushl (& prune_worktrees , "prune" , "--worktrees" , "--expire" , NULL );
293
297
argv_array_pushl (& rerere , "rerere" , "gc" , NULL );
294
298
295
299
gc_config ();
@@ -359,6 +363,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
359
363
return error (FAILED_RUN , prune .argv [0 ]);
360
364
}
361
365
366
+ if (prune_worktrees_expire ) {
367
+ argv_array_push (& prune_worktrees , prune_worktrees_expire );
368
+ if (run_command_v_opt (prune_worktrees .argv , RUN_GIT_CMD ))
369
+ return error (FAILED_RUN , prune_worktrees .argv [0 ]);
370
+ }
371
+
362
372
if (run_command_v_opt (rerere .argv , RUN_GIT_CMD ))
363
373
return error (FAILED_RUN , rerere .argv [0 ]);
364
374
0 commit comments