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

Re: [GSoC][PATCH 1/1] t1050: clean up checks for file existence

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 22, 2020, 18:03 UTC
Message-ID
<20200222180317.GF6462@camp.crustytoothpaste.net>
In-Reply-To
<xmqqtv3i5xhx.fsf@gitster-ct.c.googlers.com>
On 2020-02-22 at 17:43:06, Junio C Hamano wrote:
Show 25 quoted lines
> > @@ -65,7 +66,7 @@ test_expect_success 'add a large file or two' '
> >  	test $cnt = 2 &&
> >  	for l in .git/objects/??/??????????????????????????????????????
> 
> It is totally an unrelated tangent, but brian, are the lines of this
> kind on your radar?  The object names in SHA-256 world would not be
> caught with the pattern right?  The fix probably belongs to next to
> where OID_REGEX is defined in test-lib.sh (this is a glob and not a
> regex, though).  Perhaps the original should have been written like
> 
> 	# somewhere in test-lib.sh
> 	HEXGLOB='[0-9a-f]'
> 	HEXGLOB38=$HEXGLOB$HEXGLOB$HEXGLOB$HEXGLOB$HEXGLOB$HEXGLOB ;# 6
> 	HEXGLOB38=$HEXGLOB38$HEXGLOB38$HEXGLOB38$HEXGLOB38$HEXGLOB38$HEXGLOB38 ;# 36
> 	HEXGLOB38=$HEXGLOB$HEXGLOB$HEXGLOB38
> 
> 	OBJFANOUTGLOB=$HEXGLOB$HEXGLOB
> 	OBJFILEGLOB=$HEXGLOB38
> 
> 	...
> 
> 	for l in .git/objects/$OBJFANOUTGLOB/$OBJFILEGLOB
> 
> and then SHA-256 series would just update OBJFANOUTGLOB and
> OBJFILEGLOB patterns, or something like that?

I actually just saw that particular file the other day, but had not yet written a patch. I think we could write a pattern for that which would be useful.

We do have test_oid_to_path, which takes an object ID and inserts a slash after the first two characters, so we could do something like this:

  for l in .git/objects/$(test_oid_to_path $ZERO_OID | sed -e 's/0/[0-9a-f]/g')

That's not very readable, though. I'll try to find something a little better, or hide it somewhere behind a variable in the test setup code with a comment.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “Introduction & microproject”
  1. Rasmus JonssonFeb 22, 2020
  2. [GSoC][PATCH 1/1] t1050: clean up checks for file existenceRasmus Jonsson, Feb 22, 2020
  3. Junio C HamanoFeb 22, 2020
  4. brian m. carlsonFeb 22, 2020
  5. Junio C HamanoFeb 22, 2020
  6. Jeff KingFeb 24, 2020
  7. [GSoC][PATCH v2] t1050: replace test -f with test_path_is_fileRasmus Jonsson, Feb 23, 2020

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.