From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>, Jonathan Nieder <jrnieder@gmail.com>
Cc: Patryk Obara <patryk.obara@gmail.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH 2/5] sha1_file: fix hardcoded size in null_sha1
Date: Tue, 15 Aug 2017 11:29:55 -0700 [thread overview]
Message-ID: <CAGZ79kaCA29j6ON4KSsB=EH8FPfZGE56hVGSAAepcPiH952v6g@mail.gmail.com> (raw)
In-Reply-To: <xmqq1socsnay.fsf@gitster.mtv.corp.google.com>
On Tue, Aug 15, 2017 at 11:23 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Patryk Obara <patryk.obara@gmail.com> writes:
>
>> This prevents compilation error if GIT_MAX_RAWSZ is different than 20.
>>
>> Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
>> ---
>> sha1_file.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> I think this is OK for "null" thing, but in general I feel
> ambivalent when I see the use of "MAX" thing.
>
> Use of "MAX" here implies that we wish to support multiple hashes at
> the same time in a single binary, so that longer or shorter hashes
> fit there. But in such a case, the callers would want a union of
> some sort so that they can say "I am using SHA2, give me the null
> thing"?
>
> I said this is OK for "null" because we assume we will use ^\0{len}$
> for any hash function we choose as the "impossible" value, and for
> that particular use pattern, we do not need such a union. Just
> letting the caller peek at an appropriate number of bytes at the
> beginning of that NUL buffer for hash the caller wants to use is
> sufficient.
>
> Thanks.
Once we have 2 hash functions usable in a local Git installation,
this would be wasteful for the smaller hash function (and the
related grafts).
I think Jonathan once envisioned an 'optimized' version as a
second step, maybe this is a good time to discuss how we'd
get the right size for e.g. allocating memory, as _MAX_ seems
to be not the correct solution long term?
next prev parent reply other threads:[~2017-08-15 18:29 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 11:49 [PATCH 0/5] Modernize read_graft_line implementation Patryk Obara
2017-08-15 11:49 ` [PATCH 1/5] cache: extend object_id size to sha3-256 Patryk Obara
2017-08-15 11:49 ` [PATCH 2/5] sha1_file: fix hardcoded size in null_sha1 Patryk Obara
2017-08-15 18:23 ` Junio C Hamano
2017-08-15 18:29 ` Stefan Beller [this message]
2017-08-15 19:02 ` Junio C Hamano
2017-08-16 12:11 ` Patryk Obara
2017-08-16 19:32 ` Junio C Hamano
2017-08-15 11:49 ` [PATCH 3/5] commit: replace the raw buffer with strbuf in read_graft_line Patryk Obara
2017-08-15 17:02 ` Stefan Beller
2017-08-16 12:24 ` Patryk Obara
2017-08-16 22:59 ` brian m. carlson
2017-08-17 5:55 ` Jeff King
2017-08-17 21:17 ` Junio C Hamano
2017-08-17 21:38 ` Patryk Obara
2017-08-15 18:25 ` Junio C Hamano
2017-08-15 11:49 ` [PATCH 4/5] commit: implement free_commit_graft Patryk Obara
2017-08-15 17:04 ` Stefan Beller
2017-08-15 18:26 ` Junio C Hamano
2017-08-16 12:28 ` Patryk Obara
2017-08-15 11:49 ` [PATCH 5/5] commit: rewrite read_graft_line Patryk Obara
2017-08-15 17:11 ` Stefan Beller
2017-08-15 18:30 ` Junio C Hamano
2017-08-16 13:07 ` Patryk Obara
2017-08-16 19:39 ` Junio C Hamano
2017-08-15 17:19 ` [PATCH 0/5] Modernize read_graft_line implementation Stefan Beller
2017-08-16 17:58 ` [PATCH v2 0/4] " Patryk Obara
2017-08-16 17:58 ` [PATCH v2 1/4] sha1_file: fix hardcoded size in null_sha1 Patryk Obara
2017-08-16 19:46 ` Junio C Hamano
2017-08-16 17:58 ` [PATCH v2 2/4] commit: replace the raw buffer with strbuf in read_graft_line Patryk Obara
2017-08-16 17:58 ` [PATCH v2 3/4] commit: implement free_commit_graft Patryk Obara
2017-08-16 17:58 ` [PATCH v2 4/4] commit: rewrite read_graft_line Patryk Obara
2017-08-17 21:20 ` Junio C Hamano
2017-08-17 21:42 ` Patryk Obara
2017-08-18 1:59 ` [PATCH v3 0/4] Modernize read_graft_line implementation Patryk Obara
2017-08-18 1:59 ` [PATCH v3 1/4] sha1_file: fix definition of null_sha1 Patryk Obara
2017-08-18 1:59 ` [PATCH v3 2/4] commit: replace the raw buffer with strbuf in read_graft_line Patryk Obara
2017-08-18 6:29 ` Jeff King
2017-08-18 10:12 ` Patryk Obara
2017-08-18 11:50 ` Jeff King
2017-08-18 1:59 ` [PATCH v3 3/4] commit: allocate array using object_id size Patryk Obara
2017-08-18 1:59 ` [PATCH v3 4/4] commit: rewrite read_graft_line Patryk Obara
2017-08-18 6:43 ` Jeff King
2017-08-18 7:44 ` Junio C Hamano
2017-08-18 11:30 ` Patryk Obara
2017-08-18 11:45 ` Jeff King
2017-08-18 16:44 ` Junio C Hamano
2017-08-18 17:05 ` Patryk Obara
2017-08-18 18:29 ` Junio C Hamano
2017-08-18 2:20 ` [PATCH v3 0/4] Modernize read_graft_line implementation Junio C Hamano
2017-08-18 18:33 ` [PATCH v4 " Patryk Obara
2017-08-18 18:33 ` [PATCH v4 1/4] sha1_file: fix definition of null_sha1 Patryk Obara
2017-08-18 18:33 ` [PATCH v4 2/4] commit: replace the raw buffer with strbuf in read_graft_line Patryk Obara
2017-08-18 18:33 ` [PATCH v4 3/4] commit: allocate array using object_id size Patryk Obara
2017-08-18 18:33 ` [PATCH v4 4/4] commit: rewrite read_graft_line Patryk Obara
2017-08-18 18:38 ` Patryk Obara
2017-08-18 19:12 ` Junio C Hamano
2017-08-18 19:33 ` Patryk Obara
2017-08-18 19: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='CAGZ79kaCA29j6ON4KSsB=EH8FPfZGE56hVGSAAepcPiH952v6g@mail.gmail.com' \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=patryk.obara@gmail.com \
--cc=sandals@crustytoothpaste.net \
/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).