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

Re: [PATCH] fast-import: add options to enable/disable case folding

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 17, 2015, 19:57 UTC
Message-ID
<20150417195705.GA36902@flurp.local>
In-Reply-To
<55313B4B.3030106@web.de>
On Fri, Apr 17, 2015 at 06:56:43PM +0200, Torsten Bögershausen wrote:
Show 34 quoted lines
> On 04/17/2015 01:52 PM, Mike Hommey wrote:
> > +test_expect_success 'V: default case folding with ignorecase=true' '
> > +	git config core.ignorecase true &&
> > +	git fast-import <input &&
> > +	git ls-tree refs/heads/V >actual &&
> > +	git update-ref -d refs/heads/V &&
> > +	cat >expected <<\EOF &&
> > +100644 blob 78981922613b2afb6025042ff6bd878ac1994e85	a
> > +EOF
> > +	test_cmp expected actual'
> > +
> > +test_expect_success 'V: default case folding with ignorecase=false' '
> > +	git config core.ignorecase false &&
> > +	git fast-import <input &&
> > +	git ls-tree refs/heads/V >actual &&
> > +	git update-ref -d refs/heads/V &&
> > +	cat >expected <<\EOF &&
> > +100644 blob 78981922613b2afb6025042ff6bd878ac1994e85	A
> > +EOF
> > +	test_cmp expected actual'
> > +
> > +test_expect_success 'V: forced case folding with ignorecase=true' '
> > +	git config core.ignorecase true &&
> > +	git fast-import --fold-case <input &&
> > +	git ls-tree refs/heads/V >actual &&
> > +	git update-ref -d refs/heads/V &&
> > +	cat >expected <<\EOF &&
> > +100644 blob 78981922613b2afb6025042ff6bd878ac1994e85	a
> > +EOF
> > +	test_cmp expected actual'
>
> If you want to make it shorter (and try to avoid repetition):
> The forced true cases could be collected in a loop.
> (and the same for forced=false)

I was also going to suggest squashing the repetition. Here's what I had in mind:

--- >8 ---
test_foldcase() {
	ignore=$1 &&
	case "$2" in
	true) fold=--fold-case folded=true ;;
	false) fold=--no-fold-case folded=false ;;
	*) fold= folded=$ignore ;;
	esac &&
	case $folded in true) folded=a ;; false) folded=A ;; esac &&
	test_expect_success "V: case folding: ignorecase=$ignore${fold:+ $fold}" "
		git -c core.ignorecase=$ignore fast-import $fold <input &&
		git ls-tree refs/heads/V >actual &&
		git update-ref -d refs/heads/V &&
		cat >expect <<-EOF &&
		100644 blob 78981922613b2afb6025042ff6bd878ac1994e85	$folded
		EOF
		test_cmp expect actual
	"
}
for o in '' true false
do
	for c in true false
	do
		test_foldcase $c "$o"
	done
done
--- >8 ---
which outputs:

--- >8 --- ok 176 - V: case folding: ignorecase=true ok 177 - V: case folding: ignorecase=false ok 178 - V: case folding: ignorecase=true --fold-case ok 179 - V: case folding: ignorecase=false --fold-case ok 180 - V: case folding: ignorecase=true --no-fold-case ok 181 - V: case folding: ignorecase=false --no-fold-case --- >8 ---

Previous: Luke Diamand
Message 12 of 12 in “fast-import should not care about core.ignorecase”
  1. Mike HommeyDec 9, 2014
  2. Mike HommeyDec 9, 2014
  3. Joshua JensenDec 9, 2014
  4. Jonathan NiederDec 9, 2014
  5. Joshua JensenDec 9, 2014
  6. Junio C HamanoDec 9, 2014
  7. fast-import: add options to enable/disable case foldingMike Hommey, Apr 17, 2015
  8. Torsten BögershausenApr 17, 2015
  9. Junio C HamanoApr 17, 2015
  10. Mike HommeyApr 18, 2015
  11. Luke DiamandApr 24, 2015
  12. Eric SunshineApr 17, 2015

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.