All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] loose: don't rely on repository global state
Date: Thu, 10 Oct 2024 08:45:17 +0200	[thread overview]
Message-ID: <Zwd393AHNAGQ_zAx@pks.im> (raw)
In-Reply-To: <CAOLa=ZRMaw-PAsZ9s0zJ2zp_suMppi=ZrT67B__LU1tWZSvuUQ@mail.gmail.com>

On Wed, Oct 09, 2024 at 02:58:59AM -0700, Karthik Nayak wrote:
> In `loose.c`, we rely on the global variable `the_hash_algo`. As such we
> have guarded the file with the 'USE_THE_REPOSITORY_VARIABLE' definition.
> Let's derive the hash algorithm from the available repository variable
> and remove this guard. This brings us one step closer to removing the
> global 'the_repository' variable.
> 
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
>  loose.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/loose.c b/loose.c
> index 6d6a41b7e5..897ba389da 100644
> --- a/loose.c
> +++ b/loose.c
> @@ -1,10 +1,9 @@
> -#define USE_THE_REPOSITORY_VARIABLE
> -
>  #include "git-compat-util.h"
>  #include "hash.h"
>  #include "path.h"
>  #include "object-store.h"
>  #include "hex.h"
> +#include "repository.h"
>  #include "wrapper.h"
>  #include "gettext.h"
>  #include "loose.h"
> @@ -142,8 +141,8 @@ int repo_write_loose_object_map(struct repository *repo)
> 
>  	for (; iter != kh_end(map); iter++) {
>  		if (kh_exist(map, iter)) {
> -			if (oideq(&kh_key(map, iter), the_hash_algo->empty_tree) ||
> -			    oideq(&kh_key(map, iter), the_hash_algo->empty_blob))
> +			if (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||
> +			    oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))
>  				continue;
>  			strbuf_addf(&buf, "%s %s\n", oid_to_hex(&kh_key(map, iter)),
> oid_to_hex(kh_value(map, iter)));
>  			if (write_in_full(fd, buf.buf, buf.len) < 0)

I've already had a look internally and couldn't spot any other things
that'd need to be converted in this file. So this looks good to me,
except for the whitespace-broken parts.

Thanks!

Patrick

      parent reply	other threads:[~2024-10-10  6:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09  9:58 [PATCH] loose: don't rely on repository global state Karthik Nayak
2024-10-09 18:52 ` Junio C Hamano
2024-10-09 19:41   ` Karthik Nayak
2024-10-10  6:45 ` Patrick Steinhardt [this message]

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=Zwd393AHNAGQ_zAx@pks.im \
    --to=ps@pks.im \
    --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.