{"thread":{"id":"61966","subject":"[PATCH 0/5] dropping some more unused parameters","startedAt":"2024-08-17T07:26:22Z","lastAt":"2024-08-17T07:33:18Z","messageCount":7,"participants":["Jeff King","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"501180","messageId":"20240817072621.GA1535666@coredump.intra.peff.net","threadId":"61966","inReplyTo":null,"subject":"[PATCH 0/5] dropping some more unused parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:26:21Z","receivedAt":"2024-08-17T07:26:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"These are from my pile of -Wunused-parameter fixes. The common theme\nhere is that we're actually changing the code rather than just marking\nparameters with UNUSED. All of them just remove the parameters with the\nexception of patch 2, where we can actually make use of it (but even\nthat one is not an observable bugfix because all callers were just\npassing in the_repository anyway).\n\n  [1/5]: refs: drop some unused parameters from create_symref_lock()\n  [2/5]: pack-bitmap: load writer config from repository parameter\n  [3/5]: pack-bitmap: drop unused parameters from select_pseudo_merges()\n  [4/5]: ref-filter: drop unused parameters from email_atom_option_parser()\n  [5/5]: diff-lib: drop unused index argument from get_stat_data()\n\n diff-lib.c           | 9 +++------\n pack-bitmap-write.c  | 4 ++--\n pseudo-merge.c       | 8 ++++----\n pseudo-merge.h       | 6 +++---\n ref-filter.c         | 5 ++---\n refs/files-backend.c | 8 +++-----\n 6 files changed, 17 insertions(+), 23 deletions(-)\n\n-Peff\n"},{"id":"501181","messageId":"20240817072644.GA1535915@coredump.intra.peff.net","threadId":"61966","inReplyTo":"20240817072621.GA1535666@coredump.intra.peff.net","subject":"[PATCH 1/5] refs: drop some unused parameters from create_symref_lock()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:26:44Z","receivedAt":"2024-08-17T07:26:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This function was factored out in 57d0b1e2ea (files-backend: extract out\n`create_symref_lock()`, 2024-05-07), but we never look at the ref_store\nor refname parameters. We just need the path, which is already contained\nin the lockfile struct.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs/files-backend.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 8d6ec9458d..1cff65f6ae 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1961,9 +1961,8 @@ static int create_ref_symlink(struct ref_lock *lock, const char *target)\n \treturn ret;\n }\n \n-static int create_symref_lock(struct files_ref_store *refs,\n-\t\t\t      struct ref_lock *lock, const char *refname,\n-\t\t\t      const char *target, struct strbuf *err)\n+static int create_symref_lock(struct ref_lock *lock, const char *target,\n+\t\t\t      struct strbuf *err)\n {\n \tif (!fdopen_lock_file(&lock->lk, \"w\")) {\n \t\tstrbuf_addf(err, \"unable to fdopen %s: %s\",\n@@ -2579,8 +2578,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,\n \t}\n \n \tif (update->new_target && !(update->flags & REF_LOG_ONLY)) {\n-\t\tif (create_symref_lock(refs, lock, update->refname,\n-\t\t\t\t       update->new_target, err)) {\n+\t\tif (create_symref_lock(lock, update->new_target, err)) {\n \t\t\tret = TRANSACTION_GENERIC_ERROR;\n \t\t\tgoto out;\n \t\t}\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501182","messageId":"20240817072653.GB1535915@coredump.intra.peff.net","threadId":"61966","inReplyTo":"20240817072621.GA1535666@coredump.intra.peff.net","subject":"[PATCH 2/5] pack-bitmap: load writer config from repository parameter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:26:53Z","receivedAt":"2024-08-17T07:26:55Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"In bitmap_writer_init(), we take a repository parameter but ever look at\nit. Most of the initialization here is independent of the repository,\nbut we do load some config. So let's pass the repo we get down to\nload_pseudo_merges_from_config(), which in turn can use repo_config(),\nrather than depending on the_repository via git_config().\n\nThe outcome is the same, since all callers pass in the_repository\nanyway. But it takes us a step closer to getting rid of the global, and\nas a bonus it silences an unused parameter warning.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n pack-bitmap-write.c | 2 +-\n pseudo-merge.c      | 5 +++--\n pseudo-merge.h      | 3 ++-\n 3 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex bf96c80898..7787600234 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -51,7 +51,7 @@ void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r)\n \n \tstring_list_init_dup(&writer->pseudo_merge_groups);\n \n-\tload_pseudo_merges_from_config(&writer->pseudo_merge_groups);\n+\tload_pseudo_merges_from_config(r, &writer->pseudo_merge_groups);\n }\n \n static void free_pseudo_merge_commit_idx(struct pseudo_merge_commit_idx *idx)\ndiff --git a/pseudo-merge.c b/pseudo-merge.c\nindex 77a83b9c5c..1d7f5381a4 100644\n--- a/pseudo-merge.c\n+++ b/pseudo-merge.c\n@@ -183,11 +183,12 @@ static int pseudo_merge_config(const char *var, const char *value,\n \treturn ret;\n }\n \n-void load_pseudo_merges_from_config(struct string_list *list)\n+void load_pseudo_merges_from_config(struct repository *r,\n+\t\t\t\t    struct string_list *list)\n {\n \tstruct string_list_item *item;\n \n-\tgit_config(pseudo_merge_config, list);\n+\trepo_config(r, pseudo_merge_config, list);\n \n \tfor_each_string_list_item(item, list) {\n \t\tstruct pseudo_merge_group *group = item->util;\ndiff --git a/pseudo-merge.h b/pseudo-merge.h\nindex 2aca01d056..3aecba772b 100644\n--- a/pseudo-merge.h\n+++ b/pseudo-merge.h\n@@ -10,6 +10,7 @@ struct commit;\n struct string_list;\n struct bitmap_index;\n struct bitmap_writer;\n+struct repository;\n \n /*\n  * A pseudo-merge group tracks the set of non-bitmapped reference tips\n@@ -72,7 +73,7 @@ struct pseudo_merge_matches {\n  * entry keys are the pseudo-merge group names, and the values are\n  * pointers to the pseudo_merge_group structure itself.\n  */\n-void load_pseudo_merges_from_config(struct string_list *list);\n+void load_pseudo_merges_from_config(struct repository *r, struct string_list *list);\n \n /*\n  * A pseudo-merge commit index (pseudo_merge_commit_idx) maps a\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501183","messageId":"20240817072937.GC1535915@coredump.intra.peff.net","threadId":"61966","inReplyTo":"20240817072621.GA1535666@coredump.intra.peff.net","subject":"[PATCH 3/5] pack-bitmap: drop unused parameters from select_pseudo_merges()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:29:37Z","receivedAt":"2024-08-17T07:29:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We take the array of indexed_commits (and its length), but there's no\nneed. The selection is based on ref reachability, not the linearized set\nof commits we're packing.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nA careful reader may wonder whether we ought to be using the set of\ncommits to limit what we're willing to select (since we can't make a\nbitmap for a commit that isn't in our index).\n\nAnd this is indeed a problem, but the solution doesn't involve using\nindexed_commits. It should be fixed in this series:\n\n  https://lore.kernel.org/git/c9a64b1d2a9d6b3fe1f5fb0a7303e043114fcd8f.1723743050.git.me@ttaylorr.com/\n\n pack-bitmap-write.c | 2 +-\n pseudo-merge.c      | 3 +--\n pseudo-merge.h      | 3 +--\n 3 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7787600234..9b9ca1cc36 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -737,7 +737,7 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,\n \n \tstop_progress(&writer->progress);\n \n-\tselect_pseudo_merges(writer, indexed_commits, indexed_commits_nr);\n+\tselect_pseudo_merges(writer);\n }\n \n \ndiff --git a/pseudo-merge.c b/pseudo-merge.c\nindex 1d7f5381a4..c952a7cba9 100644\n--- a/pseudo-merge.c\n+++ b/pseudo-merge.c\n@@ -425,8 +425,7 @@ static void sort_pseudo_merge_matches(struct pseudo_merge_matches *matches)\n \tQSORT(matches->unstable, matches->unstable_nr, commit_date_cmp);\n }\n \n-void select_pseudo_merges(struct bitmap_writer *writer,\n-\t\t\t  struct commit **commits, size_t commits_nr)\n+void select_pseudo_merges(struct bitmap_writer *writer)\n {\n \tstruct progress *progress = NULL;\n \tuint32_t i;\ndiff --git a/pseudo-merge.h b/pseudo-merge.h\nindex 3aecba772b..4b5febaa63 100644\n--- a/pseudo-merge.h\n+++ b/pseudo-merge.h\n@@ -95,8 +95,7 @@ struct pseudo_merge_commit_idx {\n  *\n  * Optionally shows a progress meter.\n  */\n-void select_pseudo_merges(struct bitmap_writer *writer,\n-\t\t\t  struct commit **commits, size_t commits_nr);\n+void select_pseudo_merges(struct bitmap_writer *writer);\n \n /*\n  * Represents a serialized view of a file containing pseudo-merge(s)\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501184","messageId":"20240817072945.GD1535915@coredump.intra.peff.net","threadId":"61966","inReplyTo":"20240817072621.GA1535666@coredump.intra.peff.net","subject":"[PATCH 4/5] ref-filter: drop unused parameters from email_atom_option_parser()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:29:45Z","receivedAt":"2024-08-17T07:29:47Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This code was extracted from person_email_atom_parser() in a3d2e83a17\n(ref-filter: add mailmap support, 2023-09-25), but the part that was\nextracted doesn't care about the atom struct or the error strbuf.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n ref-filter.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 6d8b591930..2d7a65a56b 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -742,8 +742,7 @@ static int person_name_atom_parser(struct ref_format *format UNUSED,\n \treturn 0;\n }\n \n-static int email_atom_option_parser(struct used_atom *atom,\n-\t\t\t\t    const char **arg, struct strbuf *err)\n+static int email_atom_option_parser(const char **arg)\n {\n \tif (!*arg)\n \t\treturn EO_RAW;\n@@ -761,7 +760,7 @@ static int person_email_atom_parser(struct ref_format *format UNUSED,\n \t\t\t\t    const char *arg, struct strbuf *err)\n {\n \tfor (;;) {\n-\t\tint opt = email_atom_option_parser(atom, &arg, err);\n+\t\tint opt = email_atom_option_parser(&arg);\n \t\tconst char *bad_arg = arg;\n \n \t\tif (opt < 0)\n-- \n2.46.0.585.gd6679c16d8\n\n"},{"id":"501185","messageId":"20240817072949.GE1535915@coredump.intra.peff.net","threadId":"61966","inReplyTo":"20240817072621.GA1535666@coredump.intra.peff.net","subject":"[PATCH 5/5] diff-lib: drop unused index argument from get_stat_data()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-08-17T07:29:49Z","receivedAt":"2024-08-17T07:29:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The \"struct index_state\" parameter passed to get_stat_data() has been\nunused since we stopped passing it to check_removed() in 6a044a2048\n(diff-lib: fix check_removed when fsmonitor is on, 2023-09-11). We can\njust drop it, which in turns lets us simplify our callers a bit.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n diff-lib.c | 9 +++------\n 1 file changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 7a1eb63757..a680768ee7 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -308,8 +308,7 @@ static void diff_index_show_file(struct rev_info *revs,\n \t\t       oid, oid_valid, ce->name, dirty_submodule);\n }\n \n-static int get_stat_data(const struct index_state *istate,\n-\t\t\t const struct cache_entry *ce,\n+static int get_stat_data(const struct cache_entry *ce,\n \t\t\t const struct object_id **oidp,\n \t\t\t unsigned int *modep,\n \t\t\t int cached, int match_missing,\n@@ -352,7 +351,6 @@ static void show_new_file(struct rev_info *revs,\n \tconst struct object_id *oid;\n \tunsigned int mode;\n \tunsigned dirty_submodule = 0;\n-\tstruct index_state *istate = revs->diffopt.repo->index;\n \n \tif (new_file && S_ISSPARSEDIR(new_file->ce_mode)) {\n \t\tdiff_tree_oid(NULL, &new_file->oid, new_file->name, &revs->diffopt);\n@@ -363,7 +361,7 @@ static void show_new_file(struct rev_info *revs,\n \t * New file in the index: it might actually be different in\n \t * the working tree.\n \t */\n-\tif (get_stat_data(istate, new_file, &oid, &mode, cached, match_missing,\n+\tif (get_stat_data(new_file, &oid, &mode, cached, match_missing,\n \t    &dirty_submodule, &revs->diffopt) < 0)\n \t\treturn;\n \n@@ -379,7 +377,6 @@ static int show_modified(struct rev_info *revs,\n \tunsigned int mode, oldmode;\n \tconst struct object_id *oid;\n \tunsigned dirty_submodule = 0;\n-\tstruct index_state *istate = revs->diffopt.repo->index;\n \n \tassert(S_ISSPARSEDIR(old_entry->ce_mode) ==\n \t       S_ISSPARSEDIR(new_entry->ce_mode));\n@@ -395,7 +392,7 @@ static int show_modified(struct rev_info *revs,\n \t\treturn 0;\n \t}\n \n-\tif (get_stat_data(istate, new_entry, &oid, &mode, cached, match_missing,\n+\tif (get_stat_data(new_entry, &oid, &mode, cached, match_missing,\n \t\t\t  &dirty_submodule, &revs->diffopt) < 0) {\n \t\tif (report_missing)\n \t\t\tdiff_index_show_file(revs, \"-\", old_entry,\n-- \n2.46.0.585.gd6679c16d8\n"},{"id":"501186","messageId":"CAPig+cRgJkXxESSL4h+LO5FKcxKf6pt5VBWpjfUAZrrB5b0Kww@mail.gmail.com","threadId":"61966","inReplyTo":"20240817072653.GB1535915@coredump.intra.peff.net","subject":"Re: [PATCH 2/5] pack-bitmap: load writer config from repository parameter","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2024-08-17T07:33:06Z","receivedAt":"2024-08-17T07:33:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Aug 17, 2024 at 3:27 AM Jeff King <peff@peff.net> wrote:\n> In bitmap_writer_init(), we take a repository parameter but ever look at\n\ns/ever/never/\n\n> it. Most of the initialization here is independent of the repository,\n> but we do load some config. So let's pass the repo we get down to\n> load_pseudo_merges_from_config(), which in turn can use repo_config(),\n> rather than depending on the_repository via git_config().\n>\n> The outcome is the same, since all callers pass in the_repository\n> anyway. But it takes us a step closer to getting rid of the global, and\n> as a bonus it silences an unused parameter warning.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n"}]}