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

[PATCHv2 2/2] tests for git alternate command

From
Chris Packham <judge.packham@gmail.com>
Date
Mar 25, 2010, 06:07 UTC
Message-ID
<1269497251-13103-3-git-send-email-judge.packham@gmail.com>
In-Reply-To
<a038bef51003241335l1623ade4i4a9b7269546739d4@mail.gmail.com>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
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.
 t/t9800-git-alternate.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 t/t9800-git-alternate.sh
diff --git a/t/t9800-git-alternate.sh b/t/t9800-git-alternate.sh
new file mode 100644
index 0000000..e95f5bd
--- /dev/null
+++ b/t/t9800-git-alternate.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='Test of git alternate command'
+
+. ./test-lib.sh
+
+test_expect_success \
+	'Setup for rest of the test' '
+	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 .. &&
+	git clone base A &&
+	git clone A B &&
+	git clone A C &&
+	git clone A D
+'
+
+test_expect_success \
+	'Add alternate after clone' '
+	(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
+	)
+'
+
+test_expect_success \
+ 	'add same alternate fails adding existing relative path' '
+ 	(cd B &&
+ 	test_must_fail git alternate -a ../base/.git/objects
+ 	)
+'
+
+test_expect_success \
+	'Add multiple alternates' '
+	(cd C &&
+	git alternate -a ../base/.git/objects &&
+	git alternate -a ../B/.git/objects
+	)
+'
+
+test_expect_success \
+	'Add recursive alternate' '
+	(cd D &&
+	git alternate -a ../C/.git/objects
+	)
+'
+
+test_expect_success \
+	'test git alternate display' '
+	testbase=$PWD
+	(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
+	(cd D &&
+
+	git alternate -r >actual &&
+
+	{
+		echo "Object store $testbase/C/.git/objects"
+		echo "    referenced via $testbase/D/.git"
+		echo "Object store $testbase/base/.git/objects"
+		echo "    referenced via $testbase/C/.git"
+		echo "Object store $testbase/B/.git/objects"
+		echo "    referenced via $testbase/C/.git"
+		echo "Object store $testbase/base/.git/objects"
+		echo "    referenced via $testbase/B/.git"
+	} >expect &&
+
+	test_cmp expect actual
+	)
+'
+
+#rm -rf A B C D base
\ No newline at end of file
-- 
1.7.0.3
Previous: Chris PackhamNext: Johannes Sixt
Message 11 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.