-
Notifications
You must be signed in to change notification settings - Fork 145
[RFC] Maintenance III: background maintenance #680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5fdd818
41a0678
b29b686
fc741fa
e9672c6
62e8db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
/git-filter-branch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
|
||
/git-fmt-merge-msg | ||
/git-for-each-ref | ||
/git-for-each-repo | ||
/git-format-patch | ||
/git-fsck | ||
/git-fsck-objects | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
maintenance.auto:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Đoàn Trần Công Danh wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Đoàn Trần Công Danh wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Đoàn Trần Công Danh wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Derrick Stolee wrote (reply to this):
|
||
This boolean config option controls whether some commands run | ||
`git maintenance run --auto` after doing their normal work. Defaults | ||
to true. | ||
|
||
maintenance.<task>.enabled:: | ||
This boolean config option controls whether the maintenance task | ||
with name `<task>` is run when no `--task` option is specified to | ||
`git maintenance run`. These config values are ignored if a | ||
`--task` option exists. By default, only `maintenance.gc.enabled` | ||
is true. | ||
|
||
maintenance.<task>.schedule:: | ||
This config option controls whether or not the given `<task>` runs | ||
during a `git maintenance run --schedule=<frequency>` command. The | ||
value must be one of "hourly", "daily", or "weekly". | ||
|
||
maintenance.commit-graph.auto:: | ||
This integer config option controls how often the `commit-graph` task | ||
should be run as part of `git maintenance run --auto`. If zero, then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
git-for-each-repo(1) | ||
==================== | ||
|
||
NAME | ||
---- | ||
git-for-each-repo - Run a Git command on a list of repositories | ||
|
||
|
||
SYNOPSIS | ||
-------- | ||
[verse] | ||
'git for-each-repo' --config=<config> [--] <arguments> | ||
|
||
|
||
DESCRIPTION | ||
----------- | ||
Run a Git command on a list of repositories. The arguments after the | ||
known options or `--` indicator are used as the arguments for the Git | ||
subprocess. | ||
|
||
THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. | ||
|
||
For example, we could run maintenance on each of a list of repositories | ||
stored in a `maintenance.repo` config variable using | ||
|
||
------------- | ||
git for-each-repo --config=maintenance.repo maintenance run | ||
------------- | ||
|
||
This will run `git -C <repo> maintenance run` for each value `<repo>` | ||
in the multi-valued config variable `maintenance.repo`. | ||
|
||
|
||
OPTIONS | ||
------- | ||
--config=<config>:: | ||
Use the given config variable as a multi-valued list storing | ||
absolute path names. Iterate on that list of paths to run | ||
the given arguments. | ||
+ | ||
These config values are loaded from system, global, and local Git config, | ||
as available. If `git for-each-repo` is run in a directory that is not a | ||
Git repository, then only the system and global config is used. | ||
|
||
|
||
SUBPROCESS BEHAVIOR | ||
------------------- | ||
|
||
If any `git -C <repo> <arguments>` subprocess returns a non-zero exit code, | ||
then the `git for-each-repo` process returns that exit code without running | ||
more subprocesses. | ||
|
||
Each `git -C <repo> <arguments>` subprocess inherits the standard file | ||
descriptors `stdin`, `stdout`, and `stderr`. | ||
|
||
|
||
GIT | ||
--- | ||
Part of the linkgit:git[1] suite |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "cache.h" | ||
#include "config.h" | ||
#include "builtin.h" | ||
#include "parse-options.h" | ||
#include "run-command.h" | ||
#include "string-list.h" | ||
|
||
static const char * const for_each_repo_usage[] = { | ||
N_("git for-each-repo --config=<config> <command-args>"), | ||
NULL | ||
}; | ||
|
||
static int run_command_on_repo(const char *path, | ||
void *cbdata) | ||
{ | ||
int i; | ||
struct child_process child = CHILD_PROCESS_INIT; | ||
struct strvec *args = (struct strvec *)cbdata; | ||
|
||
child.git_cmd = 1; | ||
strvec_pushl(&child.args, "-C", path, NULL); | ||
|
||
for (i = 0; i < args->nr; i++) | ||
strvec_push(&child.args, args->v[i]); | ||
|
||
return run_command(&child); | ||
} | ||
|
||
int cmd_for_each_repo(int argc, const char **argv, const char *prefix) | ||
{ | ||
static const char *config_key = NULL; | ||
int i, result = 0; | ||
const struct string_list *values; | ||
struct strvec args = STRVEC_INIT; | ||
|
||
const struct option options[] = { | ||
OPT_STRING(0, "config", &config_key, N_("config"), | ||
N_("config key storing a list of repository paths")), | ||
OPT_END() | ||
}; | ||
|
||
argc = parse_options(argc, argv, prefix, options, for_each_repo_usage, | ||
PARSE_OPT_STOP_AT_NON_OPTION); | ||
|
||
if (!config_key) | ||
die(_("missing --config=<config>")); | ||
|
||
for (i = 0; i < argc; i++) | ||
strvec_push(&args, argv[i]); | ||
|
||
values = repo_config_get_value_multi(the_repository, | ||
config_key); | ||
|
||
for (i = 0; !result && i < values->nr; i++) | ||
result = run_command_on_repo(values->items[i].string, &args); | ||
|
||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Đoàn Trần Công Danh wrote (reply to this):