From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: Arnav Bhate <bhatearnav@gmail.com>, git@vger.kernel.org
Subject: Re: [GSoC PATCH] rm: fix sign comparison warnings
Date: Thu, 13 Mar 2025 08:25:24 -0700 [thread overview]
Message-ID: <xmqqmsdpq7ff.fsf@gitster.g> (raw)
In-Reply-To: <CAOLa=ZTia95Lib6bkz_nWi2BYEteAaOxsrrX9DqLTEz1t02ggA@mail.gmail.com> (Karthik Nayak's message of "Thu, 13 Mar 2025 07:25:07 -0400")
Karthik Nayak <karthik.188@gmail.com> writes:
> I have to agree. I think it would a bit cleaner to actually change the
> functions argument type itself. Perhaps, something like:
>
> -- >8 --
>
> diff --git a/builtin/rm.c b/builtin/rm.c
> index 12ae086a55..79e47d6e9e 100644
> --- a/builtin/rm.c
> +++ b/builtin/rm.c
> @@ -40,10 +40,8 @@ static struct {
> } *entry;
> } list;
>
> -static int get_ours_cache_pos(const char *path, int pos)
> +static int get_ours_cache_pos(const char *path, unsigned int i)
> {
> - int i = -pos - 1;
> -
> while ((i < the_repository->index->cache_nr) &&
> !strcmp(the_repository->index->cache[i]->name, path)) {
> if (ce_stage(the_repository->index->cache[i]) == 2)
> return i;
> @@ -83,7 +81,7 @@ static void submodules_absorb_gitdir_if_needed(void)
>
> pos = index_name_pos(the_repository->index, name, strlen(name));
> if (pos < 0) {
> - pos = get_ours_cache_pos(name, pos);
> + pos = get_ours_cache_pos(name, -pos - 1);
> if (pos < 0)
> continue;
> }
>
> @@ -131,7 +129,7 @@ static int check_local_mod(struct object_id *head,
> int index_only)
> * Skip unmerged entries except for populated submodules
> * that could lose history when removed.
> */
> - pos = get_ours_cache_pos(name, pos);
> + pos = get_ours_cache_pos(name, -pos - 1);
> if (pos < 0)
> continue;
It makes the code far easier to read to turn what index_name_pos()
returns to the index where the conflicted "our" entry ought to
appear like the above two hunks do. Makes perfect sense, even if
there weren't any type mismatch warnings.
Thanks.
next prev parent reply other threads:[~2025-03-13 15:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 20:19 [GSoC PATCH] rm: fix sign comparison warnings Arnav Bhate
2025-03-13 7:16 ` Junio C Hamano
2025-03-13 11:25 ` Karthik Nayak
2025-03-13 14:30 ` Arnav Bhate
2025-03-13 14:45 ` Karthik Nayak
2025-03-13 15:25 ` Junio C Hamano [this message]
2025-03-13 14:26 ` Arnav Bhate
2025-03-16 10:13 ` [GSoC PATCH v2] " Arnav Bhate
2025-03-17 16:47 ` Junio C Hamano
2025-03-17 17:05 ` Arnav Bhate
2025-03-17 17:07 ` [GSoC PATCH v3] " Arnav Bhate
2025-03-17 17:12 ` Arnav Bhate
2025-03-17 17:10 ` Arnav Bhate
2025-03-29 6:03 ` [GSoC PATCH v4] " Arnav Bhate
2025-03-29 6:07 ` Arnav Bhate
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=xmqqmsdpq7ff.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=bhatearnav@gmail.com \
--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 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 NNTP newsgroup(s).