From 64a6151da7fa4b36eb2818047a9b76797e25b46e Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 14 Mar 2022 08:42:46 +0100 Subject: repack: refactor to avoid double-negation of update-server-info By default, git-repack(1) runs `update_server_info()` to generate info required for the dumb HTTP protocol. This can be disabled via the `-n` flag, which then sets the `no_update_server_info` flag. Further down the code this leads to some double-negation logic, which is about to become more confusing as we're about to add a new config which allows the user to permanently disable generation of the info. Refactor the code to avoid the double-negation and add some tests which verify that the flag continues to work as expected. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t7700-repack.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 't') diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index e489869dd9..73270477e4 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -385,4 +385,36 @@ test_expect_success TTY '--quiet disables progress' ' test_must_be_empty stderr ' +test_expect_success 'setup for update-server-info' ' + git init update-server-info && + test_commit -C update-server-info message +' + +test_server_info_present () { + test_path_is_file update-server-info/.git/objects/info/packs && + test_path_is_file update-server-info/.git/info/refs +} + +test_server_info_missing () { + test_path_is_missing update-server-info/.git/objects/info/packs && + test_path_is_missing update-server-info/.git/info/refs +} + +test_server_info_cleanup () { + rm -f update-server-info/.git/objects/info/packs update-server-info/.git/info/refs && + test_server_info_missing +} + +test_expect_success 'updates server info by default' ' + test_server_info_cleanup && + git -C update-server-info repack && + test_server_info_present +' + +test_expect_success '-n skips updating server info' ' + test_server_info_cleanup && + git -C update-server-info repack -n && + test_server_info_missing +' + test_done -- cgit v1.2.3 From a2565c48e410864c049e66a64393fd6e26eb9a55 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 14 Mar 2022 08:42:51 +0100 Subject: repack: add config to skip updating server info By default, git-repack(1) will update server info that is required by the dumb HTTP transport. This can be skipped by passing the `-n` flag, but what we're noticably missing is a config option to permanently disable updating this information. Add a new option "repack.updateServerInfo" which can be used to disable the logic. Most hosting providers have turned off the dumb HTTP protocol anyway, and on the client-side it woudln't typically be useful either. Giving a persistent way to disable this feature thus makes quite some sense to avoid wasting compute cycles and storage. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t7700-repack.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 't') diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 73270477e4..a2f52a3faf 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -417,4 +417,22 @@ test_expect_success '-n skips updating server info' ' test_server_info_missing ' +test_expect_success 'repack.updateServerInfo=true updates server info' ' + test_server_info_cleanup && + git -C update-server-info -c repack.updateServerInfo=true repack && + test_server_info_present +' + +test_expect_success 'repack.updateServerInfo=false skips updating server info' ' + test_server_info_cleanup && + git -C update-server-info -c repack.updateServerInfo=false repack && + test_server_info_missing +' + +test_expect_success '-n overrides repack.updateServerInfo=true' ' + test_server_info_cleanup && + git -C update-server-info -c repack.updateServerInfo=true repack -n && + test_server_info_missing +' + test_done -- cgit v1.2.3