From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak via B4 Relay <devnull+karthik.188.gmail.com@kernel.org>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH 3/5] pack-write: pass hash_algo to `write_idx_file()`
Date: Thu, 16 Jan 2025 11:12:49 -0800 [thread overview]
Message-ID: <xmqqjzaur2ry.fsf@gitster.g> (raw)
In-Reply-To: <20250116-kn-the-repo-cleanup-v1-3-a2f4c8e1c4c3@gmail.com> (Karthik Nayak via's message of "Thu, 16 Jan 2025 12:35:15 +0100")
Karthik Nayak via B4 Relay
<devnull+karthik.188.gmail.com@kernel.org> writes:
> From: Karthik Nayak <karthik.188@gmail.com>
>
> The `write_idx_file()` function uses the global `the_hash_algo` variable
> to access the repository's hash function. To avoid global variable
> usage, pass the hash function from the layers above.
>
> Altough the layers above could have access to the hash function
> internally, simply pass in `the_hash_algo`. This avoids any
> compatibility issues and bubbles up global variable usage to upper
> layers which can be eventually resolved.
> ...
> -void stage_tmp_packfiles(struct strbuf *name_buffer,
> +void stage_tmp_packfiles(const struct git_hash_algo *hash_algo,
> + struct strbuf *name_buffer,
> const char *pack_tmp_name,
> struct pack_idx_entry **written_list,
> uint32_t nr_written,
> @@ -561,8 +563,8 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
> if (adjust_shared_perm(pack_tmp_name))
> die_errno("unable to make temporary pack file readable");
>
> - *idx_tmp_name = (char *)write_idx_file(NULL, written_list, nr_written,
> - pack_idx_opts, hash);
> + *idx_tmp_name = (char *)write_idx_file(hash_algo, NULL, written_list,
> + nr_written, pack_idx_opts, hash);
The proposed log message should mention the reason why this
stage_tmp_packfiles() function needs to be singled out among many
other direct callers of write_idx_file() function.
In other words, ...
> @@ -798,8 +798,8 @@ static const char *create_index(void)
> if (c != last)
> die("internal consistency error creating the index");
>
> - tmpfile = write_idx_file(NULL, idx, object_count, &pack_idx_opts,
> - pack_data->hash);
> + tmpfile = write_idx_file(the_hash_algo, NULL, idx, object_count,
> + &pack_idx_opts, pack_data->hash);
> free(idx);
> return tmpfile;
> }
... this hunk could have made create_index() to take a git_hash_algo
object and pass it down to write_idx_file(), while changing all the
callers of create_index() pass the_hash_algo, but we did not do so.
But stage_tmp_packfiles() got that treatment. Please tell your
readers in the proposed log message what makes it special.
Thanks.
next prev parent reply other threads:[~2025-01-16 19:12 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 11:35 [PATCH 0/5] pack-write: cleanup usage of global variables Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-16 11:35 ` [PATCH 1/5] pack-write: pass hash_algo to `fixup_pack_header_footer()` Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-16 19:35 ` Junio C Hamano
2025-01-16 11:35 ` [PATCH 2/5] pack-write: pass repository to `index_pack_lockfile()` Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-16 19:05 ` Junio C Hamano
2025-01-17 8:47 ` Karthik Nayak
2025-01-16 11:35 ` [PATCH 3/5] pack-write: pass hash_algo to `write_idx_file()` Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-16 13:24 ` Patrick Steinhardt
2025-01-17 8:56 ` Karthik Nayak
2025-01-16 19:12 ` Junio C Hamano [this message]
2025-01-17 8:58 ` Karthik Nayak
2025-01-16 11:35 ` [PATCH 4/5] pack-write: pass hash_algo to `write_rev_file()` Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-16 13:24 ` Patrick Steinhardt
2025-01-16 19:35 ` Junio C Hamano
2025-01-16 11:35 ` [PATCH 5/5] pack-write: pass hash_algo to `write_rev_*()` Karthik Nayak
2025-01-16 11:35 ` Karthik Nayak via B4 Relay
2025-01-17 9:20 ` [PATCH v2 0/5] pack-write: cleanup usage of global variables Karthik Nayak
2025-01-17 9:20 ` [PATCH v2 1/5] pack-write: pass hash_algo to `fixup_pack_header_footer()` Karthik Nayak
2025-01-17 16:38 ` Toon Claes
2025-01-17 18:06 ` Junio C Hamano
2025-01-19 11:07 ` Karthik Nayak
2025-01-17 9:20 ` [PATCH v2 2/5] pack-write: pass repository to `index_pack_lockfile()` Karthik Nayak
2025-01-17 9:20 ` [PATCH v2 3/5] pack-write: pass hash_algo to `write_idx_file()` Karthik Nayak
2025-01-17 16:40 ` Toon Claes
2025-01-19 11:10 ` Karthik Nayak
2025-01-17 9:20 ` [PATCH v2 4/5] pack-write: pass hash_algo to `write_rev_file()` Karthik Nayak
2025-01-17 9:20 ` [PATCH v2 5/5] pack-write: pass hash_algo to internal functions Karthik Nayak
2025-01-17 9:46 ` Patrick Steinhardt
2025-01-17 9:55 ` Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 0/5] pack-write: cleanup usage of global variables Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 1/5] pack-write: pass hash_algo to `fixup_pack_header_footer()` Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 2/5] pack-write: pass repository to `index_pack_lockfile()` Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 3/5] pack-write: pass hash_algo to `write_idx_file()` Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 4/5] pack-write: pass hash_algo to `write_rev_file()` Karthik Nayak
2025-01-19 11:19 ` [PATCH v3 5/5] pack-write: pass hash_algo to internal functions Karthik Nayak
2025-01-24 5:46 ` [PATCH v3 0/5] pack-write: cleanup usage of global variables Patrick Steinhardt
2025-01-24 15:47 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjzaur2ry.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=devnull+karthik.188.gmail.com@kernel.org \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.