Skip to content

Commit a25a2cd

Browse files
committed
Merge branch 'jc/receive-pack-auto' into maint
* jc/receive-pack-auto: receive-pack: run "gc --auto --quiet" and optionally "update-server-info" gc --auto --quiet: make the notice a bit less verboase
2 parents 14d52b2 + 77e3efb commit a25a2cd

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

Documentation/config.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,11 @@ rebase.stat::
13201320
Whether to show a diffstat of what changed upstream since the last
13211321
rebase. False by default.
13221322

1323+
receive.autogc::
1324+
By default, git-receive-pack will run "git-gc --auto" after
1325+
receiving data from git-push and updating refs. You can stop
1326+
it by setting this variable to false.
1327+
13231328
receive.fsckObjects::
13241329
If it is set to true, git-receive-pack will check all received
13251330
objects. It will abort in the case of a malformed object or a
@@ -1355,6 +1360,10 @@ receive.denyNonFastForwards::
13551360
even if that push is forced. This configuration variable is
13561361
set when initializing a shared repository.
13571362

1363+
receive.updateserverinfo::
1364+
If set to true, git-receive-pack will run git-update-server-info
1365+
after receiving data from git-push and updating refs.
1366+
13581367
remote.<name>.url::
13591368
The URL of a remote repository. See linkgit:git-fetch[1] or
13601369
linkgit:git-push[1].

builtin-gc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
216216
*/
217217
if (!need_to_gc())
218218
return 0;
219-
fprintf(stderr, "Auto packing your repository for optimum "
220-
"performance. You may also\n"
221-
"run \"git gc\" manually. See "
222-
"\"git help gc\" for more information.\n");
219+
fprintf(stderr,
220+
"Auto packing the repository for optimum performance.%s\n",
221+
quiet
222+
? ""
223+
: (" You may also\n"
224+
"run \"git gc\" manually. See "
225+
"\"git help gc\" for more information."));
223226
} else
224227
append_option(argv_repack,
225228
prune_expire && !strcmp(prune_expire, "now")

builtin-receive-pack.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static int transfer_unpack_limit = -1;
2828
static int unpack_limit = 100;
2929
static int report_status;
3030
static int prefer_ofs_delta = 1;
31+
static int auto_update_server_info;
32+
static int auto_gc = 1;
3133
static const char *head_name;
3234
static char *capabilities_to_send;
3335

@@ -88,6 +90,16 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
8890
return 0;
8991
}
9092

93+
if (strcmp(var, "receive.updateserverinfo") == 0) {
94+
auto_update_server_info = git_config_bool(var, value);
95+
return 0;
96+
}
97+
98+
if (strcmp(var, "receive.autogc") == 0) {
99+
auto_gc = git_config_bool(var, value);
100+
return 0;
101+
}
102+
91103
return git_default_config(var, value, cb);
92104
}
93105

@@ -672,6 +684,14 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
672684
report(unpack_status);
673685
run_receive_hook(post_receive_hook);
674686
run_update_post_hook(commands);
687+
if (auto_gc) {
688+
const char *argv_gc_auto[] = {
689+
"gc", "--auto", "--quiet", NULL,
690+
};
691+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
692+
}
693+
if (auto_update_server_info)
694+
update_server_info(0);
675695
}
676696
return 0;
677697
}

0 commit comments

Comments
 (0)