From: Junio C Hamano <gitster@pobox.com>
To: Shuqi Liang <cheskaqiqi@gmail.com>
Cc: git@vger.kernel.org, vdye@github.com
Subject: Re: [PATCH v2 1/3] Enable gitattributes read from sparse directories
Date: Fri, 07 Jul 2023 16:15:03 -0700 [thread overview]
Message-ID: <xmqqzg4771qg.fsf@gitster.g> (raw)
In-Reply-To: <20230707151839.504494-2-cheskaqiqi@gmail.com> (Shuqi Liang's message of "Fri, 7 Jul 2023 11:18:37 -0400")
Shuqi Liang <cheskaqiqi@gmail.com> writes:
> + pos = index_name_pos_sparse(istate, path, strlen(path));
> + pos = -pos-2;
With SP at appropriate places, i.e. "pos = -pos - 2".
But more importantly, where does the -2 come from? For a missing
entry, we get a negative number, and the location that the cache
entry with the given path would be inserted can be recovered by
computing -pos - 1, and that is why
if (0 <= pos) {
... handle existing ce at pos ...
} else if (pos < 0) {
pos = -pos - 1;
... if such a path were in the index, it would have
... been at pos
}
looks fairly familiar to those who have read our code. Even in such
a case, we do not blindly compute "-pos - 1", though.
In any case, this magic "adjustment" of the returned value needs to
be explained, perhaps in in-code comment around there.
> + if (!path_in_cone_mode_sparse_checkout(path, istate) && pos>=0) {
With SP at appropriate places, i.e. " && 0 <= pos".
Thanks.
next prev parent reply other threads:[~2023-07-07 23:15 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-01 6:48 [PATCH v1 0/3] check-attr: integrate with sparse-index Shuqi Liang
2023-07-01 6:48 ` [PATCH v1 1/3] attr.c: read attributes in a sparse directory Shuqi Liang
2023-07-03 17:59 ` Victoria Dye
2023-07-01 6:48 ` [PATCH v1 2/3] t1092: add tests for `git check-attr` Shuqi Liang
2023-07-03 18:11 ` Victoria Dye
2023-07-01 6:48 ` [PATCH v1 3/3] check-attr: integrate with sparse-index Shuqi Liang
2023-07-03 18:21 ` Victoria Dye
2023-07-07 15:18 ` [PATCH v2 0/3] " Shuqi Liang
2023-07-07 15:18 ` [PATCH v2 1/3] Enable gitattributes read from sparse directories Shuqi Liang
2023-07-07 23:15 ` Junio C Hamano [this message]
2023-07-07 15:18 ` [PATCH v2 2/3] t1092: add tests for `git check-attr` Shuqi Liang
2023-07-07 15:18 ` [PATCH v2 3/3] check-attr: integrate with sparse-index Shuqi Liang
2023-07-11 13:30 ` [PATCH v3 0/3] " Shuqi Liang
2023-07-11 13:30 ` [PATCH v3 1/3] attr.c: read attributes in a sparse directory Shuqi Liang
2023-07-11 21:15 ` Junio C Hamano
2023-07-11 22:08 ` Junio C Hamano
2023-07-13 20:22 ` Shuqi Liang
2023-07-13 20:13 ` Shuqi Liang
2023-07-11 21:24 ` Victoria Dye
2023-07-11 13:30 ` [PATCH v3 2/3] t1092: add tests for `git check-attr` Shuqi Liang
2023-07-11 18:52 ` Junio C Hamano
2023-07-11 20:47 ` Victoria Dye
2023-07-11 13:30 ` [PATCH v3 3/3] check-attr: integrate with sparse-index Shuqi Liang
2023-07-11 20:07 ` Junio C Hamano
2023-07-11 16:56 ` [PATCH v3 0/3] " Junio C Hamano
2023-07-18 23:29 ` [PATCH v4 " Shuqi Liang
2023-07-18 23:29 ` [PATCH v4 1/3] t1092: add tests for 'git check-attr' Shuqi Liang
2023-07-20 18:43 ` Victoria Dye
2023-07-18 23:29 ` [PATCH v4 2/3] attr.c: read attributes in a sparse directory Shuqi Liang
2023-07-20 20:18 ` Victoria Dye
2023-08-03 16:22 ` Glen Choo
2023-08-15 8:05 ` Shuqi Liang
2023-07-18 23:29 ` [PATCH v4 3/3] check-attr: integrate with sparse-index Shuqi Liang
2023-08-11 14:22 ` [PATCH v5 0/3] " Shuqi Liang
2023-08-11 14:22 ` [PATCH v5 1/3] t1092: add tests for 'git check-attr' Shuqi Liang
2023-08-11 14:22 ` [PATCH v5 2/3] attr.c: read attributes in a sparse directory Shuqi Liang
2023-08-11 14:22 ` [PATCH v5 3/3] check-attr: integrate with sparse-index Shuqi Liang
2023-08-14 16:24 ` [PATCH v5 0/3] " Victoria Dye
2023-08-14 17:10 ` 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=xmqqzg4771qg.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=cheskaqiqi@gmail.com \
--cc=git@vger.kernel.org \
--cc=vdye@github.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).