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

[PATCH 5/6] t1010: add mktree test

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2009, 18:49 UTC
Message-ID
<1241981391-19639-6-git-send-email-gitster@pobox.com>
In-Reply-To
<1241981391-19639-5-git-send-email-gitster@pobox.com>

So far mktree (which has always been a quick hack) had no test. At least give it a bit of test coverage.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t1010-mktree.sh |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100755 t/t1010-mktree.sh
diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh
new file mode 100755
index 0000000..4d9b138
--- /dev/null
+++ b/t/t1010-mktree.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+test_description='git mktree'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	for d in a a. a0
+	do
+		mkdir "$d" && echo "$d/one" >"$d/one" &&
+		git add "$d"
+	done &&
+	echo one >one &&
+	git add one &&
+	git write-tree >tree &&
+	git ls-tree $(cat tree) >top &&
+	git ls-tree -r $(cat tree) >all &&
+	test_tick &&
+	git commit -q -m one &&
+	H=$(git rev-parse HEAD) &&
+	git update-index --add --cacheinfo 160000 $H sub &&
+	test_tick &&
+	git commit -q -m two &&
+	git rev-parse HEAD^{tree} >tree.withsub &&
+	git ls-tree HEAD >top.withsub &&
+	git ls-tree -r HEAD >all.withsub
+'
+
+test_expect_success 'ls-tree piped to mktree (1)' '
+	git mktree <top >actual &&
+	test_cmp tree actual
+'
+
+test_expect_success 'ls-tree piped to mktree (2)' '
+	git mktree <top.withsub >actual &&
+	test_cmp tree.withsub actual
+'
+
+test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
+	perl -e "print reverse <>" <top |
+	git mktree >actual &&
+	test_cmp tree actual
+'
+
+test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
+	perl -e "print reverse <>" <top.withsub |
+	git mktree >actual &&
+	test_cmp tree.withsub actual
+'
+
+test_expect_failure 'mktree reads ls-tree -r output (1)' '
+	git mktree <all >actual &&
+	test_cmp tree actual
+'
+
+test_expect_failure 'mktree reads ls-tree -r output (2)' '
+	git mktree <all.withsub >actual &&
+	test_cmp tree.withsub actual
+'
+
+test_done
-- 
1.6.3.9.g6345d
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 16 in “questions about git-mktree”
  1. Jon SeymourMay 10, 2009
  2. Uwe Kleine-KönigMay 10, 2009
  3. A Large Angry SCMMay 10, 2009
  4. Jakub NarebskiMay 10, 2009
  5. Junio C HamanoMay 10, 2009
  6. Junio C HamanoMay 10, 2009
  7. 0/6 Modernize mktree somewhatJunio C Hamano, May 10, 2009
  8. 1/6 build-in git-mktreeJunio C Hamano, May 10, 2009
  9. 2/6 mktree: use parse-optionsJunio C Hamano, May 10, 2009
  10. 3/6 builtin-mktree.c: use a helper function to handle one line of inputJunio C Hamano, May 10, 2009
  11. 4/6 mktree: do not barf on a submodule commitJunio C Hamano, May 10, 2009
  12. 5/6 t1010: add mktree testJunio C Hamano, May 10, 2009
  13. 6/6 mktree --missing: allow missing objectsJunio C Hamano, May 10, 2009
  14. René ScharfeMay 10, 2009
  15. Junio C HamanoMay 11, 2009
  16. Josh MicichMay 10, 2009

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.