aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-10 11:18:59 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-10 12:41:35 -0700
commit801cfae8fd683761ae268cab8cec08e4b0f5a35b (patch)
tree85a4797110944c10bf8ffb359c61ea5af6d3b473
parentad87b5dd93f61a046236febf1becc78d0ad6452a (diff)
downloadgit-801cfae8fd683761ae268cab8cec08e4b0f5a35b.tar.gz
git-801cfae8fd683761ae268cab8cec08e4b0f5a35b.tar.xz
t1010: add mktree test
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>
-rwxr-xr-xt/t1010-mktree.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh
new file mode 100755
index 000000000..4d9b1383c
--- /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