From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> The 'git job-runner' command was introduced with a '--repo=<path>' option so a user could start a process with an explicit list of repos. However, it is more likely that we will want 'git job-runner' to start without any arguments and discover the set of repos from another source. A natural source is the Git config. The 'git job-runner' does not need to run in a Git repository, but the config could be located in the global or system config. Create the job.repo config setting as a multi-valued config option. Read all values for job.repo whenever triggering an iteration of the job loop. This allows a user to add or remove repos dynamically without restarting the job-runner. Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> --- Documentation/config/job.txt | 7 +++++++ builtin/job-runner.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Documentation/config/job.txt b/Documentation/config/job.txt index efdb76afad3..2dfed3935fa 100644 --- a/Documentation/config/job.txt +++ b/Documentation/config/job.txt @@ -4,3 +4,10 @@ job.pack-files.batchSize:: part of `git run-job pack-files`. If not specified, then a dynamic size calculation is run. See linkgit:git-run-job[1] for more details. + +job.repo:: + Store an absolute path to a repository that wants background + jobs run by `git job-runner`. This is a multi-valued config + option, but it must be stored in a config file seen by the + background runner. This may be the global or system config + depending on how `git job-runner` is launched on your system. diff --git a/builtin/job-runner.c b/builtin/job-runner.c index 135288bcaae..bed401f94bf 100644 --- a/builtin/job-runner.c +++ b/builtin/job-runner.c @@ -20,6 +20,9 @@ static int arg_repos_append(const struct option *opt, static int load_active_repos(struct string_list *repos) { + struct string_list_item *item; + const struct string_list *config_repos; + if (arg_repos.nr) { struct string_list_item *item; for (item = arg_repos.items; @@ -29,6 +32,23 @@ static int load_active_repos(struct string_list *repos) return 0; } + config_repos = git_config_get_value_multi("job.repo"); + + for (item = config_repos->items; + item && item < config_repos->items + config_repos->nr; + item++) { + DIR *dir = opendir(item->string); + + if (!dir) + continue; + + closedir(dir); + string_list_append(repos, item->string); + } + + string_list_sort(repos); + string_list_remove_duplicates(repos, 0); + return 0; } -- gitgitgadget