* [PATCH] repack: add config to skip updating server info
@ 2022-03-11 11:09 Patrick Steinhardt
2022-03-11 16:20 ` Taylor Blau
2022-03-14 7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
0 siblings, 2 replies; 7+ messages in thread
From: Patrick Steinhardt @ 2022-03-11 11:09 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 4423 bytes --]
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 <ps@pks.im>
---
Documentation/config/repack.txt | 3 +++
builtin/repack.c | 6 ++++-
t/t7700-repack.sh | 47 +++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/Documentation/config/repack.txt b/Documentation/config/repack.txt
index 9c413e177e..22bfc26afc 100644
--- a/Documentation/config/repack.txt
+++ b/Documentation/config/repack.txt
@@ -25,3 +25,6 @@ repack.writeBitmaps::
space and extra time spent on the initial repack. This has
no effect if multiple packfiles are created.
Defaults to true on bare repos, false otherwise.
+
+repack.updateServerInfo::
+ If set to false, git-repack will not run git-update-server-info.
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a75..3baa993da2 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -22,6 +22,7 @@ static int delta_base_offset = 1;
static int pack_kept_objects = -1;
static int write_bitmaps = -1;
static int use_delta_islands;
+static int no_update_server_info = 0;
static char *packdir, *packtmp_name, *packtmp;
static const char *const git_repack_usage[] = {
@@ -54,6 +55,10 @@ static int repack_config(const char *var, const char *value, void *cb)
use_delta_islands = git_config_bool(var, value);
return 0;
}
+ if (strcmp(var, "repack.updateserverinfo") == 0) {
+ no_update_server_info = !git_config_bool(var, value);
+ return 0;
+ }
return git_default_config(var, value, cb);
}
@@ -620,7 +625,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
const char *unpack_unreachable = NULL;
int keep_unreachable = 0;
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
- int no_update_server_info = 0;
struct pack_objects_args po_args = {NULL};
int geometric_factor = 0;
int write_midx = 0;
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 5922fb5bdd..f049120022 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -381,4 +381,51 @@ test_expect_success TTY '--quiet disables progress' '
test_must_be_empty stderr
'
+test_expect_success 'updates server info by default' '
+ git init repo &&
+ test_when_finished "rm -rf repo" &&
+ test_commit -C repo message &&
+ test_path_is_missing repo/.git/objects/info/packs &&
+ test_path_is_missing repo/.git/info/refs &&
+ git -C repo repack &&
+ test_path_is_file repo/.git/objects/info/packs &&
+ test_path_is_file repo/.git/info/refs
+'
+
+test_expect_success '-n skips updating server info' '
+ git init repo &&
+ test_when_finished "rm -rf repo" &&
+ test_commit -C repo message &&
+ git -C repo repack -n &&
+ test_path_is_missing repo/.git/objects/info/packs &&
+ test_path_is_missing repo/.git/info/refs
+'
+
+test_expect_success 'repack.updateServerInfo=true updates server info' '
+ git init repo &&
+ test_when_finished "rm -rf repo" &&
+ test_commit -C repo message &&
+ git -C repo -c repack.updateServerInfo=true repack &&
+ test_path_is_file repo/.git/objects/info/packs &&
+ test_path_is_file repo/.git/info/refs
+'
+
+test_expect_success 'repack.updateServerInfo=false skips updating server info' '
+ git init repo &&
+ test_when_finished "rm -rf repo" &&
+ test_commit -C repo message &&
+ git -C repo -c repack.updateServerInfo=false repack &&
+ test_path_is_missing repo/.git/objects/info/packs &&
+ test_path_is_missing repo/.git/info/refs
+'
+
+test_expect_success '-n overrides repack.updateServerInfo=true' '
+ git init repo &&
+ test_when_finished "rm -rf repo" &&
+ test_commit -C repo message &&
+ git -C repo -c repack.updateServerInfo=true repack -n &&
+ test_path_is_missing repo/.git/objects/info/packs &&
+ test_path_is_missing repo/.git/info/refs
+'
+
test_done
--
2.35.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] repack: add config to skip updating server info
2022-03-11 11:09 [PATCH] repack: add config to skip updating server info Patrick Steinhardt
@ 2022-03-11 16:20 ` Taylor Blau
2022-03-14 7:19 ` Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
1 sibling, 1 reply; 7+ messages in thread
From: Taylor Blau @ 2022-03-11 16:20 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: git
On Fri, Mar 11, 2022 at 12:09:30PM +0100, Patrick Steinhardt wrote:
> diff --git a/Documentation/config/repack.txt b/Documentation/config/repack.txt
> index 9c413e177e..22bfc26afc 100644
> --- a/Documentation/config/repack.txt
> +++ b/Documentation/config/repack.txt
> @@ -25,3 +25,6 @@ repack.writeBitmaps::
> space and extra time spent on the initial repack. This has
> no effect if multiple packfiles are created.
> Defaults to true on bare repos, false otherwise.
> +
> +repack.updateServerInfo::
> + If set to false, git-repack will not run git-update-server-info.
Can you clarify here what the default value of this config variable is,
and how it interacts with repack's `-n` flag? E.g., something along the
lines of:
repack.updateServerInfo::
If set to false, linkgit:git-repack[1] will not run
linkgit:git-update-serve-info[1]. Defaults to true. Can be
overridden when true by the `-n` option of
linkgit:git-repack[1].
Perhaps a little verbose, but I think it leaves less ambiguity about
what this new configuration variable is for.
> diff --git a/builtin/repack.c b/builtin/repack.c
> index da1e364a75..3baa993da2 100644
> --- a/builtin/repack.c
> +++ b/builtin/repack.c
> @@ -22,6 +22,7 @@ static int delta_base_offset = 1;
> static int pack_kept_objects = -1;
> static int write_bitmaps = -1;
> static int use_delta_islands;
> +static int no_update_server_info = 0;
Not the fault of this patch, but I wonder if this would be less
confusing if we stored `update_server_info` instead of
`no_update_server_info`. If you have time, I think it may be worth a
preparatory patch at the beginning to swap the two.
> +test_expect_success 'updates server info by default' '
> + git init repo &&
> + test_when_finished "rm -rf repo" &&
> + test_commit -C repo message &&
> + test_path_is_missing repo/.git/objects/info/packs &&
> + test_path_is_missing repo/.git/info/refs &&
> + git -C repo repack &&
> + test_path_is_file repo/.git/objects/info/packs &&
> + test_path_is_file repo/.git/info/refs
> +'
I wonder if this and the below tests might be cleaned up with a pair of
helper functions, perhaps:
test_server_info_present () {
test_path_is_file .git/objects/info/packs &&
test_path_is_file .git/info/refs
}
test_server_info_missing () {
test_path_is_missing .git/objects/info/packs &&
test_path_is_missing .git/info/refs
}
t7700 has a mix of styles, but it may shorten some of the lines to use a
subshell that is changed into the repo directory, e.g., the test above
would become:
test_expect_success 'updates server info by default' '
git init repo &&
test_when_finished "rm -fr repo" &&
(
test_commit message &&
test_server_info_missing &&
git repack &&
test_server_info_present
)
'
which reads a little more easily to me. It would be nice to avoid
creating the sub-repos at all, perhaps by removing these files
ourselves in between tests.
> +test_expect_success '-n skips updating server info' '
> +test_expect_success 'repack.updateServerInfo=true updates server info' '
> +test_expect_success 'repack.updateServerInfo=false skips updating server info' '
> +test_expect_success '-n overrides repack.updateServerInfo=true' '
Great, these four and the above together cover all of the cases I think
we'd be interested in.
Thanks,
Taylor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] repack: add config to skip updating server info
2022-03-11 16:20 ` Taylor Blau
@ 2022-03-14 7:19 ` Patrick Steinhardt
0 siblings, 0 replies; 7+ messages in thread
From: Patrick Steinhardt @ 2022-03-14 7:19 UTC (permalink / raw)
To: Taylor Blau; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 2078 bytes --]
On Fri, Mar 11, 2022 at 11:20:41AM -0500, Taylor Blau wrote:
> On Fri, Mar 11, 2022 at 12:09:30PM +0100, Patrick Steinhardt wrote:
> > diff --git a/Documentation/config/repack.txt b/Documentation/config/repack.txt
> > index 9c413e177e..22bfc26afc 100644
> > --- a/Documentation/config/repack.txt
> > +++ b/Documentation/config/repack.txt
> > @@ -25,3 +25,6 @@ repack.writeBitmaps::
> > space and extra time spent on the initial repack. This has
> > no effect if multiple packfiles are created.
> > Defaults to true on bare repos, false otherwise.
> > +
> > +repack.updateServerInfo::
> > + If set to false, git-repack will not run git-update-server-info.
>
> Can you clarify here what the default value of this config variable is,
> and how it interacts with repack's `-n` flag? E.g., something along the
> lines of:
>
> repack.updateServerInfo::
> If set to false, linkgit:git-repack[1] will not run
> linkgit:git-update-serve-info[1]. Defaults to true. Can be
> overridden when true by the `-n` option of
> linkgit:git-repack[1].
>
> Perhaps a little verbose, but I think it leaves less ambiguity about
> what this new configuration variable is for.
Makes sense.
> > diff --git a/builtin/repack.c b/builtin/repack.c
> > index da1e364a75..3baa993da2 100644
> > --- a/builtin/repack.c
> > +++ b/builtin/repack.c
> > @@ -22,6 +22,7 @@ static int delta_base_offset = 1;
> > static int pack_kept_objects = -1;
> > static int write_bitmaps = -1;
> > static int use_delta_islands;
> > +static int no_update_server_info = 0;
>
> Not the fault of this patch, but I wonder if this would be less
> confusing if we stored `update_server_info` instead of
> `no_update_server_info`. If you have time, I think it may be worth a
> preparatory patch at the beginning to swap the two.
[snip]
I indeed first had a look at how to do this, but didn't find a negated
`OPT_BOOL()`. I had another look now though, and it seems like this is
typically solved via `OPT_NEGBIT()`.
Thanks!
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 0/2] repack: add config to skip updating server info
2022-03-11 11:09 [PATCH] repack: add config to skip updating server info Patrick Steinhardt
2022-03-11 16:20 ` Taylor Blau
@ 2022-03-14 7:42 ` Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 1/2] repack: refactor to avoid double-negation of update-server-info Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 2/2] repack: add config to skip updating server info Patrick Steinhardt
1 sibling, 2 replies; 7+ messages in thread
From: Patrick Steinhardt @ 2022-03-14 7:42 UTC (permalink / raw)
To: git; +Cc: Taylor Blau
[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]
Hi,
this is the second version of my patch series which adds a new config to
allow users and admins to permanently skip updating server info required
for the dumb HTTP protocol in git-repack(1).
The following things changed in comparison to v1:
- I've split out a preparatory patch which refactors the logic to
avoid double-negation of the `no_update_server_info` field.
- I've updated documentation to be more explicit with regards to the
default of the new config and to mention that the `-n` flag
overrides it.
- I've refactored tests to be less verbose.
Thanks for your feedback, Taylor!
Patrick
Patrick Steinhardt (2):
repack: refactor to avoid double-negation of update-server-info
repack: add config to skip updating server info
Documentation/config/repack.txt | 5 ++++
builtin/repack.c | 12 +++++---
t/t7700-repack.sh | 50 +++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 4 deletions(-)
--
2.35.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] repack: refactor to avoid double-negation of update-server-info
2022-03-14 7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
@ 2022-03-14 7:42 ` Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 2/2] repack: add config to skip updating server info Patrick Steinhardt
1 sibling, 0 replies; 7+ messages in thread
From: Patrick Steinhardt @ 2022-03-14 7:42 UTC (permalink / raw)
To: git; +Cc: Taylor Blau
[-- Attachment #1: Type: text/plain, Size: 3321 bytes --]
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 <ps@pks.im>
---
builtin/repack.c | 8 ++++----
t/t7700-repack.sh | 32 ++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a75..f2ac8ad14b 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -620,7 +620,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
const char *unpack_unreachable = NULL;
int keep_unreachable = 0;
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
- int no_update_server_info = 0;
+ int run_update_server_info = 1;
struct pack_objects_args po_args = {NULL};
int geometric_factor = 0;
int write_midx = 0;
@@ -637,8 +637,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
N_("pass --no-reuse-delta to git-pack-objects")),
OPT_BOOL('F', NULL, &po_args.no_reuse_object,
N_("pass --no-reuse-object to git-pack-objects")),
- OPT_BOOL('n', NULL, &no_update_server_info,
- N_("do not run git-update-server-info")),
+ OPT_NEGBIT('n', NULL, &run_update_server_info,
+ N_("do not run git-update-server-info"), 1),
OPT__QUIET(&po_args.quiet, N_("be quiet")),
OPT_BOOL('l', "local", &po_args.local,
N_("pass --local to git-pack-objects")),
@@ -939,7 +939,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
prune_shallow(PRUNE_QUICK);
}
- if (!no_update_server_info)
+ if (run_update_server_info)
update_server_info(0);
remove_temporary_files();
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 5922fb5bdd..6b387bbdbe 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -381,4 +381,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
--
2.35.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] repack: add config to skip updating server info
2022-03-14 7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 1/2] repack: refactor to avoid double-negation of update-server-info Patrick Steinhardt
@ 2022-03-14 7:42 ` Patrick Steinhardt
2022-03-14 22:26 ` Junio C Hamano
1 sibling, 1 reply; 7+ messages in thread
From: Patrick Steinhardt @ 2022-03-14 7:42 UTC (permalink / raw)
To: git; +Cc: Taylor Blau
[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]
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 <ps@pks.im>
---
Documentation/config/repack.txt | 5 +++++
builtin/repack.c | 6 +++++-
t/t7700-repack.sh | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/Documentation/config/repack.txt b/Documentation/config/repack.txt
index 9c413e177e..41ac6953c8 100644
--- a/Documentation/config/repack.txt
+++ b/Documentation/config/repack.txt
@@ -25,3 +25,8 @@ repack.writeBitmaps::
space and extra time spent on the initial repack. This has
no effect if multiple packfiles are created.
Defaults to true on bare repos, false otherwise.
+
+repack.updateServerInfo::
+ If set to false, linkgit:git-repack[1] will not run
+ linkgit:git-update-server-info[1]. Defaults to true. Can be overridden
+ when true by the `-n` option of linkgit:git-repack[1].
diff --git a/builtin/repack.c b/builtin/repack.c
index f2ac8ad14b..d1a563d5b6 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -22,6 +22,7 @@ static int delta_base_offset = 1;
static int pack_kept_objects = -1;
static int write_bitmaps = -1;
static int use_delta_islands;
+static int run_update_server_info = 1;
static char *packdir, *packtmp_name, *packtmp;
static const char *const git_repack_usage[] = {
@@ -54,6 +55,10 @@ static int repack_config(const char *var, const char *value, void *cb)
use_delta_islands = git_config_bool(var, value);
return 0;
}
+ if (strcmp(var, "repack.updateserverinfo") == 0) {
+ run_update_server_info = git_config_bool(var, value);
+ return 0;
+ }
return git_default_config(var, value, cb);
}
@@ -620,7 +625,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
const char *unpack_unreachable = NULL;
int keep_unreachable = 0;
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
- int run_update_server_info = 1;
struct pack_objects_args po_args = {NULL};
int geometric_factor = 0;
int write_midx = 0;
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 6b387bbdbe..770d143204 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -413,4 +413,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
--
2.35.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] repack: add config to skip updating server info
2022-03-14 7:42 ` [PATCH v2 2/2] repack: add config to skip updating server info Patrick Steinhardt
@ 2022-03-14 22:26 ` Junio C Hamano
0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2022-03-14 22:26 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: git, Taylor Blau
Patrick Steinhardt <ps@pks.im> writes:
> 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.
Makes sense. Perhaps we can leave a NEEDSWORK comment somewhere to
flip the default to false in two years or so.
Will queue.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-03-14 22:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 11:09 [PATCH] repack: add config to skip updating server info Patrick Steinhardt
2022-03-11 16:20 ` Taylor Blau
2022-03-14 7:19 ` Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 1/2] repack: refactor to avoid double-negation of update-server-info Patrick Steinhardt
2022-03-14 7:42 ` [PATCH v2 2/2] repack: add config to skip updating server info Patrick Steinhardt
2022-03-14 22:26 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).