@matheusbsbs / matheus-bagliano / commits / 77e3efbf43
Fork 0

receive-pack: run "gc --auto --quiet" and optionally "update-server-info"

Introduce two new configuration variables, receive.autogc (defaults to true) and receive.updateserverinfo (defaults to false). When these are set, receive-pack runs "gc --auto --quiet" and "update-server-info" respectively after it finishes receiving data from "git push" and updating refs. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Nicolas Pitre <nico@fluxnic.net>

Junio C Hamano committed Oct 20, 2009 at 14:56 UTC 77e3efbf43a1060049121350cc3ae8c208e77d57
2 files changed +29
Documentation/config.txt
+9
@@ -1320,6 +1320,11 @@ rebase.stat::
1320 Whether to show a diffstat of what changed upstream since the last
1321 rebase. False by default.
1322
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 +
1328 receive.fsckObjects::
1329 If it is set to true, git-receive-pack will check all received
1330 objects. It will abort in the case of a malformed object or a
@@ -1355,6 +1360,10 @@ receive.denyNonFastForwards::
1360 even if that push is forced. This configuration variable is
1361 set when initializing a shared repository.
1362
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 +
1367 remote.<name>.url::
1368 The URL of a remote repository. See linkgit:git-fetch[1] or
1369 linkgit:git-push[1].
builtin-receive-pack.c
+20
@@ -28,6 +28,8 @@ static int transfer_unpack_limit = -1;
28 static int unpack_limit = 100;
29 static int report_status;
30 static int prefer_ofs_delta = 1;
31 +static int auto_update_server_info;
32 +static int auto_gc = 1;
33 static const char *head_name;
34 static char *capabilities_to_send;
35
@@ -88,6 +90,16 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
90 return 0;
91 }
92
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 +
103 return git_default_config(var, value, cb);
104 }
105
@@ -672,6 +684,14 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
684 report(unpack_status);
685 run_receive_hook(post_receive_hook);
686 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);
695 }
696 return 0;
697 }