{"thread":{"id":"66830","subject":"[PATCH] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules","startedAt":"2026-11-12T06:33:08Z","lastAt":"2026-11-15T04:36:21Z","messageCount":4,"participants":["Srujith A Poojary via GitGitGadget","René Scharfe","Srujith Poojary"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"558277","messageId":"pull.2308.git.1794465188325.gitgitgadget@gmail.com","threadId":"66830","inReplyTo":null,"subject":"[PATCH] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-12T06:33:08Z","receivedAt":"2026-11-12T06:33:08Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nRefactor archive-tar.c, archive-zip.c, archive.c, builtin/archive.c,\nbuiltin/upload-archive.c, and diagnose.c to accept and pass explicit\nstruct repository pointers instead of relying on global repository state.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2308%2Fpoojarysrujith%2Farchive-refactor-clean-v1-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2308/poojarysrujith/archive-refactor-clean-v1-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2308\n\n archive-tar.c            | 7 +++----\n archive-zip.c            | 3 ++-\n archive.c                | 6 +++---\n archive.h                | 6 +++---\n builtin/archive.c        | 2 +-\n builtin/upload-archive.c | 2 +-\n diagnose.c               | 2 +-\n 7 files changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex a1c66024d4..5243446701 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -2,7 +2,6 @@\n  * Copyright (c) 2005, 2006 Rene Scharfe\n  */\n \n-#define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n #include \"config.h\"\n@@ -337,7 +336,7 @@ static void write_global_extended_header(struct archiver_args *args)\n \tif (oid)\n \t\tstrbuf_append_ext_header(&ext_header, \"comment\",\n \t\t\t\t\t oid_to_hex(oid),\n-\t\t\t\t\t the_hash_algo->hexsz);\n+\t\t\t\t\t args->repo->hash_algo->hexsz);\n \tif (args->time > USTAR_MAX_MTIME) {\n \t\tstrbuf_append_ext_header_uint(&ext_header, \"mtime\",\n \t\t\t\t\t      args->time);\n@@ -526,7 +525,7 @@ static struct archiver tar_archiver = {\n \t.flags = ARCHIVER_REMOTE,\n };\n \n-void init_tar_archiver(void)\n+void init_tar_archiver(struct repository *repo)\n {\n \tint i;\n \tregister_archiver(&tar_archiver);\n@@ -535,7 +534,7 @@ void init_tar_archiver(void)\n \ttar_filter_config(\"tar.tgz.remote\", \"true\", NULL);\n \ttar_filter_config(\"tar.tar.gz.command\", internal_gzip_command, NULL);\n \ttar_filter_config(\"tar.tar.gz.remote\", \"true\", NULL);\n-\trepo_config(the_repository, git_tar_config, NULL);\n+\trepo_config(repo, git_tar_config, NULL);\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\t/* omit any filters that never had a command configured */\n \t\tif (tar_filters[i]->filter_command)\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 279c3a2d72..b02fb9be38 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -655,7 +655,8 @@ static struct archiver zip_archiver = {\n \t.flags = ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE,\n };\n \n-void init_zip_archiver(void)\n+void init_zip_archiver(struct repository *repo)\n {\n+\t(void)repo;\n \tregister_archiver(&zip_archiver);\n }\ndiff --git a/archive.c b/archive.c\nindex 59790be986..e9e2e241c3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -43,10 +43,10 @@ void register_archiver(struct archiver *ar)\n \tarchivers[nr_archivers++] = ar;\n }\n \n-void init_archivers(void)\n+void init_archivers(struct repository *repo)\n {\n-\tinit_tar_archiver();\n-\tinit_zip_archiver();\n+\tinit_tar_archiver(repo);\n+\tinit_zip_archiver(repo);\n }\n \n static void format_subst(const struct commit *commit,\ndiff --git a/archive.h b/archive.h\nindex bbe65ba0f9..8ec59b22e9 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -48,9 +48,9 @@ struct archiver {\n };\n void register_archiver(struct archiver *);\n \n-void init_tar_archiver(void);\n-void init_zip_archiver(void);\n-void init_archivers(void);\n+void init_tar_archiver(struct repository *repo);\n+void init_zip_archiver(struct repository *repo);\n+void init_archivers(struct repository *repo);\n \n typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n \t\t\t\t\tconst struct object_id *oid,\ndiff --git a/builtin/archive.c b/builtin/archive.c\nindex 3c1288a123..2c01d7b6e7 100644\n--- a/builtin/archive.c\n+++ b/builtin/archive.c\n@@ -97,7 +97,7 @@ int cmd_archive(int argc,\n \targc = parse_options(argc, argv, prefix, local_opts, NULL,\n \t\t\t     PARSE_OPT_KEEP_ALL);\n \n-\tinit_archivers();\n+\tinit_archivers(repo);\n \n \tif (output)\n \t\tcreate_output_file(output);\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex 718e74b3ac..3cfc7ffaf3 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -34,7 +34,7 @@ int cmd_upload_archive_writer(int argc,\n \tif (!enter_repo(the_repository, argv[1], 0))\n \t\tdie(\"'%s' does not appear to be a git repository\", argv[1]);\n \n-\tinit_archivers();\n+\tinit_archivers(the_repository);\n \n \t/* put received options in sent_argv[] */\n \tstrvec_push(&sent_argv, \"git-upload-archive\");\ndiff --git a/diagnose.c b/diagnose.c\nindex 2c1bcfe431..c642dde351 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -212,7 +212,7 @@ int create_diagnostics_archive(struct repository *r,\n \t\tgoto diagnose_cleanup;\n \t}\n \n-\tinit_zip_archiver();\n+\tinit_zip_archiver(r);\n \tstrvec_pushl(&archiver_args, \"git-diagnose\", \"--format=zip\", NULL);\n \n \tstrbuf_reset(&buf);\n\nbase-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2\n-- \ngitgitgadget\n\n"},{"id":"558481","messageId":"71280528-f044-49ab-b746-4f680f220627@web.de","threadId":"66830","inReplyTo":"pull.2308.git.1794465188325.gitgitgadget@gmail.com","subject":"Re: [PATCH] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-11-14T19:26:44Z","receivedAt":"2026-11-14T19:26:44Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"On 11/12/26 7:33 AM, Srujith A Poojary via GitGitGadget wrote:\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n> \n> Refactor archive-tar.c, archive-zip.c, archive.c, builtin/archive.c,\n> builtin/upload-archive.c, and diagnose.c to accept and pass explicit\n> struct repository pointers instead of relying on global repository state.\n> \n> Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> ---\n>     archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2308%2Fpoojarysrujith%2Farchive-refactor-clean-v1-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2308/poojarysrujith/archive-refactor-clean-v1-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/2308\n> \n>  archive-tar.c            | 7 +++----\n>  archive-zip.c            | 3 ++-\n>  archive.c                | 6 +++---\n>  archive.h                | 6 +++---\n>  builtin/archive.c        | 2 +-\n>  builtin/upload-archive.c | 2 +-\n>  diagnose.c               | 2 +-\n>  7 files changed, 14 insertions(+), 14 deletions(-)\n> \n> diff --git a/archive-tar.c b/archive-tar.c\n> index a1c66024d4..5243446701 100644\n> --- a/archive-tar.c\n> +++ b/archive-tar.c\n> @@ -2,7 +2,6 @@\n>   * Copyright (c) 2005, 2006 Rene Scharfe\n>   */\n>  \n> -#define USE_THE_REPOSITORY_VARIABLE\n>  \n>  #include \"git-compat-util.h\"\n>  #include \"config.h\"\n> @@ -337,7 +336,7 @@ static void write_global_extended_header(struct archiver_args *args)\n>  \tif (oid)\n>  \t\tstrbuf_append_ext_header(&ext_header, \"comment\",\n>  \t\t\t\t\t oid_to_hex(oid),\n> -\t\t\t\t\t the_hash_algo->hexsz);\n> +\t\t\t\t\t args->repo->hash_algo->hexsz);\n>  \tif (args->time > USTAR_MAX_MTIME) {\n>  \t\tstrbuf_append_ext_header_uint(&ext_header, \"mtime\",\n>  \t\t\t\t\t      args->time);\n> @@ -526,7 +525,7 @@ static struct archiver tar_archiver = {\n>  \t.flags = ARCHIVER_REMOTE,\n>  };\n>  \n> -void init_tar_archiver(void)\n> +void init_tar_archiver(struct repository *repo)\n>  {\n>  \tint i;\n>  \tregister_archiver(&tar_archiver);\n> @@ -535,7 +534,7 @@ void init_tar_archiver(void)\n>  \ttar_filter_config(\"tar.tgz.remote\", \"true\", NULL);\n>  \ttar_filter_config(\"tar.tar.gz.command\", internal_gzip_command, NULL);\n>  \ttar_filter_config(\"tar.tar.gz.remote\", \"true\", NULL);\n> -\trepo_config(the_repository, git_tar_config, NULL);\n> +\trepo_config(repo, git_tar_config, NULL);\n>  \tfor (i = 0; i < nr_tar_filters; i++) {\n>  \t\t/* omit any filters that never had a command configured */\n>  \t\tif (tar_filters[i]->filter_command)\n> diff --git a/archive-zip.c b/archive-zip.c\n> index 279c3a2d72..b02fb9be38 100644\n> --- a/archive-zip.c\n> +++ b/archive-zip.c\n> @@ -655,7 +655,8 @@ static struct archiver zip_archiver = {\n>  \t.flags = ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE,\n>  };\n>  \n> -void init_zip_archiver(void)\n> +void init_zip_archiver(struct repository *repo)\n>  {\n> +\t(void)repo;\n>  \tregister_archiver(&zip_archiver);\n>  }\n\nSo repo is not actually used here.  Why pass it in?  It's not like the\ninit functions all need have the same signature.\n\nNot shown here: archive-zip.c still sets USE_THE_REPOSITORY_VARIABLE.\nPerhaps dealing with that is better left to a separate patch, but the\ncommit message should reflect that only the tar format handler is\ntreated here.\n\n> diff --git a/archive.c b/archive.c\n> index 59790be986..e9e2e241c3 100644\n> --- a/archive.c\n> +++ b/archive.c\n> @@ -43,10 +43,10 @@ void register_archiver(struct archiver *ar)\n>  \tarchivers[nr_archivers++] = ar;\n>  }\n>  \n> -void init_archivers(void)\n> +void init_archivers(struct repository *repo)\n>  {\n> -\tinit_tar_archiver();\n> -\tinit_zip_archiver();\n> +\tinit_tar_archiver(repo);\n> +\tinit_zip_archiver(repo);\n>  }\n>  \n>  static void format_subst(const struct commit *commit,\n> diff --git a/archive.h b/archive.h\n> index bbe65ba0f9..8ec59b22e9 100644\n> --- a/archive.h\n> +++ b/archive.h\n> @@ -48,9 +48,9 @@ struct archiver {\n>  };\n>  void register_archiver(struct archiver *);\n>  \n> -void init_tar_archiver(void);\n> -void init_zip_archiver(void);\n> -void init_archivers(void);\n> +void init_tar_archiver(struct repository *repo);\n> +void init_zip_archiver(struct repository *repo);\n> +void init_archivers(struct repository *repo);\n>  \n>  typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n>  \t\t\t\t\tconst struct object_id *oid,\n> diff --git a/builtin/archive.c b/builtin/archive.c\n> index 3c1288a123..2c01d7b6e7 100644\n> --- a/builtin/archive.c\n> +++ b/builtin/archive.c\n> @@ -97,7 +97,7 @@ int cmd_archive(int argc,\n>  \targc = parse_options(argc, argv, prefix, local_opts, NULL,\n>  \t\t\t     PARSE_OPT_KEEP_ALL);\n>  \n> -\tinit_archivers();\n> +\tinit_archivers(repo);\n>  \n>  \tif (output)\n>  \t\tcreate_output_file(output);\n> diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\n> index 718e74b3ac..3cfc7ffaf3 100644\n> --- a/builtin/upload-archive.c\n> +++ b/builtin/upload-archive.c\n> @@ -34,7 +34,7 @@ int cmd_upload_archive_writer(int argc,\n>  \tif (!enter_repo(the_repository, argv[1], 0))\n>  \t\tdie(\"'%s' does not appear to be a git repository\", argv[1]);\n>  \n> -\tinit_archivers();\n> +\tinit_archivers(the_repository);\n>  \n>  \t/* put received options in sent_argv[] */\n>  \tstrvec_push(&sent_argv, \"git-upload-archive\");\n> diff --git a/diagnose.c b/diagnose.c\n> index 2c1bcfe431..c642dde351 100644\n> --- a/diagnose.c\n> +++ b/diagnose.c\n> @@ -212,7 +212,7 @@ int create_diagnostics_archive(struct repository *r,\n>  \t\tgoto diagnose_cleanup;\n>  \t}\n>  \n> -\tinit_zip_archiver();\n> +\tinit_zip_archiver(r);\n>  \tstrvec_pushl(&archiver_args, \"git-diagnose\", \"--format=zip\", NULL);\n>  \n>  \tstrbuf_reset(&buf);\n> \n> base-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2\n\n\n"},{"id":"558490","messageId":"pull.2308.v2.git.1794717327255.gitgitgadget@gmail.com","threadId":"66830","inReplyTo":"pull.2308.git.1794465188325.gitgitgadget@gmail.com","subject":"[PATCH v2] archive: pass explicit repository to tar archiver init","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-15T04:35:27Z","receivedAt":"2026-11-15T04:35:27Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nRefactor init_tar_archiver() and init_archivers() to accept and pass an\nexplicit struct repository pointer for tar's repository-dependent\nconfiguration, removing USE_THE_REPOSITORY_VARIABLE from archive-tar.c.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2308%2Fpoojarysrujith%2Farchive-refactor-clean-v1-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2308/poojarysrujith/archive-refactor-clean-v1-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2308\n\nRange-diff vs v1:\n\n 1:  b733b5d396 ! 1:  6f0d7bf698 archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n     @@ Metadata\n      Author: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n       ## Commit message ##\n     -    archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n     +    archive: pass explicit repository to tar archiver init\n      \n     -    Refactor archive-tar.c, archive-zip.c, archive.c, builtin/archive.c,\n     -    builtin/upload-archive.c, and diagnose.c to accept and pass explicit\n     -    struct repository pointers instead of relying on global repository state.\n     +    Refactor init_tar_archiver() and init_archivers() to accept and pass an\n     +    explicit struct repository pointer for tar's repository-dependent\n     +    configuration, removing USE_THE_REPOSITORY_VARIABLE from archive-tar.c.\n      \n          Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n     @@ archive-tar.c: void init_tar_archiver(void)\n       \t\t/* omit any filters that never had a command configured */\n       \t\tif (tar_filters[i]->filter_command)\n      \n     - ## archive-zip.c ##\n     -@@ archive-zip.c: static struct archiver zip_archiver = {\n     - \t.flags = ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE,\n     - };\n     - \n     --void init_zip_archiver(void)\n     -+void init_zip_archiver(struct repository *repo)\n     - {\n     -+\t(void)repo;\n     - \tregister_archiver(&zip_archiver);\n     - }\n     -\n       ## archive.c ##\n      @@ archive.c: void register_archiver(struct archiver *ar)\n       \tarchivers[nr_archivers++] = ar;\n     @@ archive.c: void register_archiver(struct archiver *ar)\n      +void init_archivers(struct repository *repo)\n       {\n      -\tinit_tar_archiver();\n     --\tinit_zip_archiver();\n      +\tinit_tar_archiver(repo);\n     -+\tinit_zip_archiver(repo);\n     + \tinit_zip_archiver();\n       }\n       \n     - static void format_subst(const struct commit *commit,\n      \n       ## archive.h ##\n      @@ archive.h: struct archiver {\n     @@ archive.h: struct archiver {\n       void register_archiver(struct archiver *);\n       \n      -void init_tar_archiver(void);\n     --void init_zip_archiver(void);\n     --void init_archivers(void);\n      +void init_tar_archiver(struct repository *repo);\n     -+void init_zip_archiver(struct repository *repo);\n     + void init_zip_archiver(void);\n     +-void init_archivers(void);\n      +void init_archivers(struct repository *repo);\n       \n       typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n     @@ builtin/upload-archive.c: int cmd_upload_archive_writer(int argc,\n       \n       \t/* put received options in sent_argv[] */\n       \tstrvec_push(&sent_argv, \"git-upload-archive\");\n     -\n     - ## diagnose.c ##\n     -@@ diagnose.c: int create_diagnostics_archive(struct repository *r,\n     - \t\tgoto diagnose_cleanup;\n     - \t}\n     - \n     --\tinit_zip_archiver();\n     -+\tinit_zip_archiver(r);\n     - \tstrvec_pushl(&archiver_args, \"git-diagnose\", \"--format=zip\", NULL);\n     - \n     - \tstrbuf_reset(&buf);\n\n\n archive-tar.c            | 7 +++----\n archive.c                | 4 ++--\n archive.h                | 4 ++--\n builtin/archive.c        | 2 +-\n builtin/upload-archive.c | 2 +-\n 5 files changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex a1c66024d4..5243446701 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -2,7 +2,6 @@\n  * Copyright (c) 2005, 2006 Rene Scharfe\n  */\n \n-#define USE_THE_REPOSITORY_VARIABLE\n \n #include \"git-compat-util.h\"\n #include \"config.h\"\n@@ -337,7 +336,7 @@ static void write_global_extended_header(struct archiver_args *args)\n \tif (oid)\n \t\tstrbuf_append_ext_header(&ext_header, \"comment\",\n \t\t\t\t\t oid_to_hex(oid),\n-\t\t\t\t\t the_hash_algo->hexsz);\n+\t\t\t\t\t args->repo->hash_algo->hexsz);\n \tif (args->time > USTAR_MAX_MTIME) {\n \t\tstrbuf_append_ext_header_uint(&ext_header, \"mtime\",\n \t\t\t\t\t      args->time);\n@@ -526,7 +525,7 @@ static struct archiver tar_archiver = {\n \t.flags = ARCHIVER_REMOTE,\n };\n \n-void init_tar_archiver(void)\n+void init_tar_archiver(struct repository *repo)\n {\n \tint i;\n \tregister_archiver(&tar_archiver);\n@@ -535,7 +534,7 @@ void init_tar_archiver(void)\n \ttar_filter_config(\"tar.tgz.remote\", \"true\", NULL);\n \ttar_filter_config(\"tar.tar.gz.command\", internal_gzip_command, NULL);\n \ttar_filter_config(\"tar.tar.gz.remote\", \"true\", NULL);\n-\trepo_config(the_repository, git_tar_config, NULL);\n+\trepo_config(repo, git_tar_config, NULL);\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\t/* omit any filters that never had a command configured */\n \t\tif (tar_filters[i]->filter_command)\ndiff --git a/archive.c b/archive.c\nindex 59790be986..50063c24ab 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -43,9 +43,9 @@ void register_archiver(struct archiver *ar)\n \tarchivers[nr_archivers++] = ar;\n }\n \n-void init_archivers(void)\n+void init_archivers(struct repository *repo)\n {\n-\tinit_tar_archiver();\n+\tinit_tar_archiver(repo);\n \tinit_zip_archiver();\n }\n \ndiff --git a/archive.h b/archive.h\nindex bbe65ba0f9..10d76de4c0 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -48,9 +48,9 @@ struct archiver {\n };\n void register_archiver(struct archiver *);\n \n-void init_tar_archiver(void);\n+void init_tar_archiver(struct repository *repo);\n void init_zip_archiver(void);\n-void init_archivers(void);\n+void init_archivers(struct repository *repo);\n \n typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n \t\t\t\t\tconst struct object_id *oid,\ndiff --git a/builtin/archive.c b/builtin/archive.c\nindex 3c1288a123..2c01d7b6e7 100644\n--- a/builtin/archive.c\n+++ b/builtin/archive.c\n@@ -97,7 +97,7 @@ int cmd_archive(int argc,\n \targc = parse_options(argc, argv, prefix, local_opts, NULL,\n \t\t\t     PARSE_OPT_KEEP_ALL);\n \n-\tinit_archivers();\n+\tinit_archivers(repo);\n \n \tif (output)\n \t\tcreate_output_file(output);\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex 718e74b3ac..3cfc7ffaf3 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -34,7 +34,7 @@ int cmd_upload_archive_writer(int argc,\n \tif (!enter_repo(the_repository, argv[1], 0))\n \t\tdie(\"'%s' does not appear to be a git repository\", argv[1]);\n \n-\tinit_archivers();\n+\tinit_archivers(the_repository);\n \n \t/* put received options in sent_argv[] */\n \tstrvec_push(&sent_argv, \"git-upload-archive\");\n\nbase-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2\n-- \ngitgitgadget\n\n"},{"id":"558491","messageId":"CABh_KWhWZt=Ng9PTr+NcFxO=9pLx+vdvYpo6=JW8Z6WUzZ3HpQ@mail.gmail.com","threadId":"66830","inReplyTo":"71280528-f044-49ab-b746-4f680f220627@web.de","subject":"Re: [PATCH] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-11-15T04:36:21Z","receivedAt":"2026-11-15T04:36:21Z","isPatch":true,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"On Sun, Nov 15, 2026 at 12:56 AM René Scharfe <l.s.r@web.de> wrote:\n>\n> On 11/12/26 7:33 AM, Srujith A Poojary via GitGitGadget wrote:\n> > From: Srujith A Poojary <poojarysrujith@gmail.com>\n> >\n> > Refactor archive-tar.c, archive-zip.c, archive.c, builtin/archive.c,\n> > builtin/upload-archive.c, and diagnose.c to accept and pass explicit\n> > struct repository pointers instead of relying on global repository state.\n> >\n> > Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> > ---\n> >     archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules\n> >\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2308%2Fpoojarysrujith%2Farchive-refactor-clean-v1-v1\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2308/poojarysrujith/archive-refactor-clean-v1-v1\n> > Pull-Request: https://github.com/gitgitgadget/git/pull/2308\n> >\n> >  archive-tar.c            | 7 +++----\n> >  archive-zip.c            | 3 ++-\n> >  archive.c                | 6 +++---\n> >  archive.h                | 6 +++---\n> >  builtin/archive.c        | 2 +-\n> >  builtin/upload-archive.c | 2 +-\n> >  diagnose.c               | 2 +-\n> >  7 files changed, 14 insertions(+), 14 deletions(-)\n> >\n> > diff --git a/archive-tar.c b/archive-tar.c\n> > index a1c66024d4..5243446701 100644\n> > --- a/archive-tar.c\n> > +++ b/archive-tar.c\n> > @@ -2,7 +2,6 @@\n> >   * Copyright (c) 2005, 2006 Rene Scharfe\n> >   */\n> >\n> > -#define USE_THE_REPOSITORY_VARIABLE\n> >\n> >  #include \"git-compat-util.h\"\n> >  #include \"config.h\"\n> > @@ -337,7 +336,7 @@ static void write_global_extended_header(struct archiver_args *args)\n> >       if (oid)\n> >               strbuf_append_ext_header(&ext_header, \"comment\",\n> >                                        oid_to_hex(oid),\n> > -                                      the_hash_algo->hexsz);\n> > +                                      args->repo->hash_algo->hexsz);\n> >       if (args->time > USTAR_MAX_MTIME) {\n> >               strbuf_append_ext_header_uint(&ext_header, \"mtime\",\n> >                                             args->time);\n> > @@ -526,7 +525,7 @@ static struct archiver tar_archiver = {\n> >       .flags = ARCHIVER_REMOTE,\n> >  };\n> >\n> > -void init_tar_archiver(void)\n> > +void init_tar_archiver(struct repository *repo)\n> >  {\n> >       int i;\n> >       register_archiver(&tar_archiver);\n> > @@ -535,7 +534,7 @@ void init_tar_archiver(void)\n> >       tar_filter_config(\"tar.tgz.remote\", \"true\", NULL);\n> >       tar_filter_config(\"tar.tar.gz.command\", internal_gzip_command, NULL);\n> >       tar_filter_config(\"tar.tar.gz.remote\", \"true\", NULL);\n> > -     repo_config(the_repository, git_tar_config, NULL);\n> > +     repo_config(repo, git_tar_config, NULL);\n> >       for (i = 0; i < nr_tar_filters; i++) {\n> >               /* omit any filters that never had a command configured */\n> >               if (tar_filters[i]->filter_command)\n> > diff --git a/archive-zip.c b/archive-zip.c\n> > index 279c3a2d72..b02fb9be38 100644\n> > --- a/archive-zip.c\n> > +++ b/archive-zip.c\n> > @@ -655,7 +655,8 @@ static struct archiver zip_archiver = {\n> >       .flags = ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE,\n> >  };\n> >\n> > -void init_zip_archiver(void)\n> > +void init_zip_archiver(struct repository *repo)\n> >  {\n> > +     (void)repo;\n> >       register_archiver(&zip_archiver);\n> >  }\n>\n> So repo is not actually used here.  Why pass it in?  It's not like the\n> init functions all need have the same signature.\n>\n> Not shown here: archive-zip.c still sets USE_THE_REPOSITORY_VARIABLE.\n> Perhaps dealing with that is better left to a separate patch, but the\n> commit message should reflect that only the tar format handler is\n> treated here.\n>\n> > diff --git a/archive.c b/archive.c\n> > index 59790be986..e9e2e241c3 100644\n> > --- a/archive.c\n> > +++ b/archive.c\n> > @@ -43,10 +43,10 @@ void register_archiver(struct archiver *ar)\n> >       archivers[nr_archivers++] = ar;\n> >  }\n> >\n> > -void init_archivers(void)\n> > +void init_archivers(struct repository *repo)\n> >  {\n> > -     init_tar_archiver();\n> > -     init_zip_archiver();\n> > +     init_tar_archiver(repo);\n> > +     init_zip_archiver(repo);\n> >  }\n> >\n> >  static void format_subst(const struct commit *commit,\n> > diff --git a/archive.h b/archive.h\n> > index bbe65ba0f9..8ec59b22e9 100644\n> > --- a/archive.h\n> > +++ b/archive.h\n> > @@ -48,9 +48,9 @@ struct archiver {\n> >  };\n> >  void register_archiver(struct archiver *);\n> >\n> > -void init_tar_archiver(void);\n> > -void init_zip_archiver(void);\n> > -void init_archivers(void);\n> > +void init_tar_archiver(struct repository *repo);\n> > +void init_zip_archiver(struct repository *repo);\n> > +void init_archivers(struct repository *repo);\n> >\n> >  typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n> >                                       const struct object_id *oid,\n> > diff --git a/builtin/archive.c b/builtin/archive.c\n> > index 3c1288a123..2c01d7b6e7 100644\n> > --- a/builtin/archive.c\n> > +++ b/builtin/archive.c\n> > @@ -97,7 +97,7 @@ int cmd_archive(int argc,\n> >       argc = parse_options(argc, argv, prefix, local_opts, NULL,\n> >                            PARSE_OPT_KEEP_ALL);\n> >\n> > -     init_archivers();\n> > +     init_archivers(repo);\n> >\n> >       if (output)\n> >               create_output_file(output);\n> > diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\n> > index 718e74b3ac..3cfc7ffaf3 100644\n> > --- a/builtin/upload-archive.c\n> > +++ b/builtin/upload-archive.c\n> > @@ -34,7 +34,7 @@ int cmd_upload_archive_writer(int argc,\n> >       if (!enter_repo(the_repository, argv[1], 0))\n> >               die(\"'%s' does not appear to be a git repository\", argv[1]);\n> >\n> > -     init_archivers();\n> > +     init_archivers(the_repository);\n> >\n> >       /* put received options in sent_argv[] */\n> >       strvec_push(&sent_argv, \"git-upload-archive\");\n> > diff --git a/diagnose.c b/diagnose.c\n> > index 2c1bcfe431..c642dde351 100644\n> > --- a/diagnose.c\n> > +++ b/diagnose.c\n> > @@ -212,7 +212,7 @@ int create_diagnostics_archive(struct repository *r,\n> >               goto diagnose_cleanup;\n> >       }\n> >\n> > -     init_zip_archiver();\n> > +     init_zip_archiver(r);\n> >       strvec_pushl(&archiver_args, \"git-diagnose\", \"--format=zip\", NULL);\n> >\n> >       strbuf_reset(&buf);\n> >\n> > base-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2\n>\n\nHi René,\n\nThank you for the review! That makes complete sense.\n\nI have updated the patch to address your feedback:\n- Reverted `init_zip_archiver()` and `archive-zip.c` back to their\noriginal clean state, keeping zip out of this patch scope.\n- Narrowed the commit strictly to updating `init_tar_archiver()` and\nits initialization path to accept and pass the explicit `struct\nrepository *repo` pointer.\n\nThe updated version (v2) has been pushed. Thanks again for your guidance!\n\nBest regards,\nSrujith\n\n"}]}