From: Junio C Hamano <gitster@pobox.com>
To: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de, peff@peff.net,
jnareb@gmail.com, pclouds@gmail.com, carenas@gmail.com,
avarab@gmail.com, Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH v4 3/6] commit-graph: turn on commit-graph by default
Date: Sun, 19 Sep 2021 17:42:57 -0700 [thread overview]
Message-ID: <xmqq8rzsdqlq.fsf@gitster.g> (raw)
In-Reply-To: 651e2d526b2a3f6c63c64cfe1f049eef94d39c07.1565721461.git.gitgitgadget@gmail.com
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> diff --git a/repo-settings.c b/repo-settings.c
> index 309577f6bc..d00b675687 100644
> --- a/repo-settings.c
> +++ b/repo-settings.c
> @@ -2,6 +2,8 @@
> #include "config.h"
> #include "repository.h"
>
> +#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
> +
> void prepare_repo_settings(struct repository *r)
> {
> int value;
> @@ -16,6 +18,8 @@ void prepare_repo_settings(struct repository *r)
> r->settings.core_commit_graph = value;
> if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
> r->settings.gc_write_commit_graph = value;
> + UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
> + UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
This is a "review comment" that is more than 2 years late X-<, but I
noticed that this is used to muck with a structure that was
initialized by filling it with \0377 bytes.
+ /* Defaults */
+ memset(&r->settings, -1, sizeof(r->settings));
but the structure is is full of "int" and "enum", so apparently this
works only on 2's complement architecture.
struct repo_settings {
int initialized;
int core_commit_graph;
int commit_graph_read_changed_paths;
int gc_write_commit_graph;
int fetch_write_commit_graph;
int index_version;
enum untracked_cache_setting core_untracked_cache;
int pack_use_sparse;
enum fetch_negotiation_setting fetch_negotiation_algorithm;
int core_multi_pack_index;
unsigned command_requires_full_index:1,
sparse_index:1;
};
I see that the earliest iteration of this series [*1*] set the
default explicitly using assignments of the correct types, like
this:
+void prepare_repo_settings(struct repository *r)
+{
+ if (r->settings)
+ return;
+
+ r->settings = xmalloc(sizeof(*r->settings));
+
+ /* Defaults */
+ r->settings->core_commit_graph = -1;
+ r->settings->gc_write_commit_graph = -1;
+ r->settings->pack_use_sparse = -1;
+ r->settings->index_version = -1;
+ ...
which I think should be a reasonable starting point to fix the
current code.
Another thing I noticed is that while it may have been only for
setting the default value for a boolean variable initially, other
changes abuse the macro to set an arbitrary integer values to
integer members of the structure, e.g. c6cc4c5a (repo-settings:
create feature.manyFiles setting, 2019-08-13) sets 4 to the
index_version (naturally, the choice between 0 and 1 does not make
much sense for the member), and ad0fb659 (repo-settings: parse
core.untrackedCache, 2019-08-13) stuffs UNTRACKED_CACHE_* enum to
core_untracked_cache. The UPDATE_DEFAULT_BOOL() macro should be
renamed to UPDATE_DEFAULT_INT() at least, I would think, to save
readers from confusion.
Thanks.
[Reference]
*1* https://lore.kernel.org/git/72f652b89c71526cc423e7812de66f41a079f181.1563818059.git.gitgitgadget@gmail.com/
next prev parent reply other threads:[~2021-09-20 0:43 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 17:54 [PATCH 0/5] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-07-22 17:54 ` [PATCH 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-23 13:12 ` Johannes Schindelin
2019-07-22 17:54 ` [PATCH 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-23 14:53 ` Johannes Schindelin
2019-07-24 10:41 ` Derrick Stolee
2019-07-22 17:54 ` [PATCH 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-22 17:54 ` [PATCH 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-23 15:04 ` Johannes Schindelin
2019-07-24 19:27 ` Derrick Stolee
2019-07-22 17:54 ` [PATCH 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-07-23 15:20 ` Johannes Schindelin
2019-07-25 1:47 ` Derrick Stolee
2019-07-25 2:23 ` [PATCH v2 0/5] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-25 9:30 ` Johannes Schindelin
2019-07-25 2:23 ` [PATCH v2 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-25 9:36 ` Johannes Schindelin
2019-07-25 2:23 ` [PATCH v2 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-25 2:23 ` [PATCH v2 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-07-25 9:40 ` [PATCH v2 0/5] Create 'feature.*' config area and some centralized config parsing Johannes Schindelin
2019-07-30 19:35 ` [PATCH v3 " Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 1/5] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-07-30 20:47 ` Junio C Hamano
2019-07-30 19:35 ` [PATCH v3 2/5] repo-settings: add feature.manyCommits setting Derrick Stolee via GitGitGadget
2019-07-30 20:57 ` Junio C Hamano
2019-07-31 13:17 ` Johannes Schindelin
2019-07-31 15:48 ` Junio C Hamano
2019-07-31 15:01 ` Ævar Arnfjörð Bjarmason
2019-08-01 18:27 ` Derrick Stolee
2019-07-30 19:35 ` [PATCH v3 4/5] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 3/5] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-07-30 19:35 ` [PATCH v3 5/5] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-08-08 18:34 ` Elijah Newren
2019-08-08 18:48 ` Derrick Stolee
2019-08-08 18:59 ` Junio C Hamano
2019-08-08 19:12 ` Derrick Stolee
2019-08-08 20:31 ` Elijah Newren
2019-08-08 20:49 ` Derrick Stolee
2019-08-08 19:19 ` Elijah Newren
2019-08-08 20:07 ` Junio C Hamano
2019-08-08 20:46 ` Derrick Stolee
2019-08-13 18:37 ` [PATCH v4 0/6] Create 'feature.*' config area and some centralized config parsing Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 1/6] repo-settings: consolidate some config settings Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 3/6] commit-graph: turn on commit-graph by default Derrick Stolee via GitGitGadget
2021-09-20 0:42 ` Junio C Hamano [this message]
2021-09-20 1:22 ` Ævar Arnfjörð Bjarmason
2021-09-20 1:25 ` brian m. carlson
2021-09-20 12:53 ` Phillip Wood
2021-09-20 13:30 ` Ævar Arnfjörð Bjarmason
2021-09-20 18:00 ` Phillip Wood
2021-09-20 19:18 ` Jeff King
2019-08-13 18:37 ` [PATCH v4 2/6] t6501: use 'git gc' in quiet mode Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 4/6] repo-settings: parse core.untrackedCache Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 5/6] repo-settings: create feature.manyFiles setting Derrick Stolee via GitGitGadget
2019-08-13 18:37 ` [PATCH v4 6/6] repo-settings: create feature.experimental setting Derrick Stolee via GitGitGadget
2019-08-13 21:04 ` [PATCH v4 0/6] Create 'feature.*' config area and some centralized config parsing Junio C Hamano
2019-08-13 21:08 ` Junio C Hamano
2019-08-14 10:32 ` Derrick Stolee
2019-08-14 10:38 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq8rzsdqlq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=carenas@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jnareb@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).