git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sha1_file: add slash once in for_each_file_in_obj_subdir()

From
Jeff King <peff@peff.net>
Date
Jul 10, 2017, 00:06 UTC
Message-ID
<20170710000638.p7foedomfmdakyww@sigill.intra.peff.net>
In-Reply-To
<xmqqy3rx8svk.fsf@gitster.mtv.corp.google.com>
On Sun, Jul 09, 2017 at 09:41:51AM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> > On the plus side, this moves an invariant out of the loop. On the minus
> > side, it has to introduce an extra variable for "length we add on to"
> > versus "dir length to pass to the subdir_cb". That's not rocket science,
> > but it does slightly complicate things (though I note we already have
> > "origlen", so this is bumping us from 2 to 3 length variables, not 1 to
> > 2).
> >
> > So I dunno. It's fine with me if we take it, and fine if we leave it.
> 
> Unlike origlen, base vs dir lengths are not strictly needed; we
> prepare the base including '/', and we know we always have just one
> '/' at the end, so anybody that uses dirlen to truncate it back to
> the original before passing it down can truncate to (baselen-1), no?
> 
> In other words, something like this (not an incremental but a
> replacement) to keep calling "baselen" the length of the leading
> constant part we append to?

Yeah, I think that is correct. And you could even drop origlen by replacing it with "baselen - 3" at the end. But somehow doing the computation on the fly actually seems more complicated to me (from the perspective of a reader who is trying to make sure all is correct).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “sha1_file: add slash once in for_each_file_in_obj_subdir()”
  1. sha1_file: add slash once in for_each_file_in_obj_subdir()René Scharfe, Jul 8, 2017
  2. Jeff KingJul 9, 2017
  3. René ScharfeJul 9, 2017
  4. Junio C HamanoJul 9, 2017
  5. Jeff KingJul 10, 2017
  6. Junio C HamanoJul 10, 2017
  7. René ScharfeJul 12, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.