git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Thomas Gummerer <t.gummerer@gmail.com>
Subject: Re: [PATCH 2/3] http-push: use hex_to_bytes()
Date: Wed, 1 Nov 2017 18:15:42 -0400	[thread overview]
Message-ID: <20171101221541.6dwezd4t4hweuis2@sigill.intra.peff.net> (raw)
In-Reply-To: <0e7f821a-94ae-3946-fb99-c508a06a6847@web.de>

On Wed, Nov 01, 2017 at 10:59:49PM +0100, René Scharfe wrote:

> > The hex_to_bytes() function requires that the caller make sure they have
> > the right number of bytes. But for many callers, I think they'd want to
> > say "parse this oid, which might be truncated; I can't tell what the
> > length is supposed to be".
> 
> I'm confused by the word "many".  After this series there are three
> callers of hex_to_bytes() and I don't expect that number to grow.

I meant only that most callers that parse oids, both in-file and not,
would want to stop knowing about the length ahead of time. I think
parse_oid_hex() solves that problem for most callers.

> Would loose objects be stored at paths containing only a subset of their
> new hash value?  If they won't then there will be two acceptable lengths
> instead of the one we have today, which should be easy to handle.

I don't know. TBH, I'm not sure anyone has much interest in making
http-push work with new hashes. I'd be OK if it simply doesn't until
somebody interested shows up to change that.

> > We don't need to deal with that eventuality yet, but I'm on the fence on
> > whether this patch is making that harder down the road or not. The
> > current strategy of "stuff it into a buffer without slashes" would be
> > easier to convert, I think.
> 
> How so?  If you have a buffer then you need to know the size of the
> data to copy into it as well, or you'll learn it in the process.
> 
> The call sites of hex_to_bytes() have to be modified along with the
> functions in hex.c to support longer hashes, with or without this
> series.

You have to know how big the data you have is, but you don't necessarily
know whether that makes a complete hash or not. With a "remove slashes
and then parse" strategy, you can do the removing without worrying about
how big things are _supposed_ to be, and then the parser can tell you if
you have a valid oid or not. The logic for what a hash looks like _and_
how big it must be are both in the parser.

With the new code you have here, we have to be a bit more intimate with
SHA1_HEXSZ in the calling code. It knows that the hash consists of a
certain number of hex bytes.

I'm perfectly willing to punt on it for now. I'm not sure we know 100%
yet what "new"-style hashes will look like, nor how their loose-object
filenames would look.

-Peff

  reply	other threads:[~2017-11-01 22:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 13:46 [PATCH 1/3] notes: move hex_to_bytes() to hex.c and export it René Scharfe
2017-10-31 13:49 ` [PATCH 2/3] http-push: use hex_to_bytes() René Scharfe
2017-11-01 19:55   ` Jeff King
2017-11-01 21:59     ` René Scharfe
2017-11-01 22:15       ` Jeff King [this message]
2017-11-04  9:05         ` René Scharfe
2017-10-31 13:50 ` [PATCH 3/3] sha1_file: " René Scharfe
2017-11-01 19:58   ` Jeff King
2017-11-05  2:56 ` [PATCH 1/3] notes: move hex_to_bytes() to hex.c and export it Kevin Daudt
2017-11-05 16:47   ` René Scharfe
2017-11-05 19:57     ` Kevin Daudt

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171101221541.6dwezd4t4hweuis2@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=mhagger@alum.mit.edu \
    --cc=sandals@crustytoothpaste.net \
    --cc=t.gummerer@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).