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

Re: [PATCHv2 2/2] tests for git alternate command

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 25, 2010, 07:38 UTC
Message-ID
<4BAB12E1.8070602@viscovery.net>
In-Reply-To
<1269497251-13103-3-git-send-email-judge.packham@gmail.com>
Am 3/25/2010 7:07, schrieb Chris Packham:
> Signed-off-by: Chris Packham <judge.packham@gmail.com>

Your patches violate whitespace rules. Use 'git show --check' to see the questionable lines.

> ---
> I wasn't sure about the test numbering so I just grabbed the highest one. Still
> need to add tests for the deletion use case.
According to t/README, t1* would be a suitable category, perhaps t1430.
>  t/t9800-git-alternate.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++++
"git" in the name is redundant
> +test_expect_success \
> +	'Setup for rest of the test' '
The modern style for test headers is
test_expect_success 'Setup for rest of the test' '
	test goes here
'
It may improve readability if you insert a blank line after the headline.
Show 9 quoted lines
> +	mkdir -p base &&
> +	cd base &&
> +	git init &&
> +	echo test > a.txt &&
> +	echo test > b.txt &&
> +	echo test > c.txt &&
> +	git add *.txt &&
> +	git commit -a -m "Initial Commit" &&
> +	cd .. &&

Do not use 'cd dir && ... && cd ..', use (cd dir && ...) like you did in the rest of the tests.

Show 5 quoted lines
> +test_expect_success \
> +	'Add alternate after clone' '
> +	(cd B &&
> +	git alternate -a ../base/.git/objects
> +	)
We saw tests like this written with more whitespace like:
	(
		cd B &&
		git alternate -a ../base/.git/objects
	)
> +test_expect_success \
> +	'add same alternate fails adding existing abs path' '
> +	(cd B &&
> +	test_must_fail git alternate -a $PWD/base/.git/objects

This use of $PWD is OK, but for consistency it should be $(pwd) like below. Moreover, it needs double-quotes.

> +test_expect_success \
> +	'test git alternate display' '
> +	testbase=$PWD
You must write this as (d-quotes not needed here)
	testbase=$(pwd) &&

for the benefit of Windows. The difference is that $PWD returns /c/path, but $(pwd) returns c:/path.

When the alternate was set up using the command, git has only ever seen a c:/path style path (regardless of whether you used $PWD or $(pwd), because the path is converted to c:/path by the shell before it invokes git), and therefore the alternates file contains this style.

But when the expected result is constructed, the /c/path style is *not* converted to c:/path; and a mismatch would be detected.

Show 13 quoted lines
> +	(cd B &&
> +	git alternate >actual &&
> +	{
> +		echo "Object store $testbase/base/.git/objects"
> +		echo "    referenced via $testbase/B/.git"
> +	} >expect &&
> +	test_cmp expect actual
> +	)
> +'
> +
> +test_expect_success \
> +	'test git alternate recursive display' '
> +	testbase=$PWD
Ditto.
> +#rm -rf A B C D base
> \ No newline at end of file
test_done
-- Hannes
Previous: Chris PackhamNext: Chris Packham
Message 12 of 17 in “Question about .git/objects/info/alternates”
  1. Chris PackhamMar 22, 2010
  2. Jonathan NiederMar 23, 2010
  3. Chris PackhamMar 24, 2010
  4. Jonathan NiederMar 24, 2010
  5. Junio C HamanoMar 24, 2010
  6. Chris PackhamMar 24, 2010
  7. Chris PackhamMar 25, 2010
  8. 1/2 Add git alternate commandChris Packham, Mar 25, 2010
  9. Junio C HamanoMar 29, 2010
  10. Chris PackhamMar 31, 2010
  11. 2/2 tests for git alternate commandChris Packham, Mar 25, 2010
  12. Johannes SixtMar 25, 2010
  13. Chris PackhamMar 25, 2010
  14. Miklos VajnaMar 26, 2010
  15. Johannes SixtMar 26, 2010
  16. Stephen BoydMar 24, 2010
  17. Chris PackhamMar 24, 2010

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.