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

[PATCH 1/2] t3101: test more ls-tree options

From
Stephen Boyd <bebarino@gmail.com>
Date
Nov 14, 2009, 04:34 UTC
Message-ID
<1258173248-31059-2-git-send-email-bebarino@gmail.com>
In-Reply-To
<1258173248-31059-1-git-send-email-bebarino@gmail.com>
Add tests for --full-name, --full-tree, --abbrev, and --name-only.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
 t/t3101-ls-tree-dirname.sh |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 51cb4a3..99458e4 100755
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -39,8 +39,8 @@ test_expect_success \
      tree=`git write-tree` &&
      echo $tree'
 
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+_x5='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x5$_x5$_x5$_x5$_x5$_x5$_x5$_x5"
 test_output () {
     sed -e "s/ $_x40	/ X	/" <current >check
     test_cmp expected check
@@ -141,4 +141,89 @@ test_expect_success 'ls-tree filter is leading path match' '
 	test_output
 '
 
+test_expect_success 'ls-tree --full-name' '
+	(
+		cd path0 &&
+		git ls-tree --full-name $tree a
+	) > current &&
+	cat >expected <<\EOF &&
+040000 tree X	path0/a
+EOF
+	test_output
+'
+
+test_expect_success 'ls-tree --full-tree' '
+	(
+		cd path1/b/c &&
+		git ls-tree --full-tree $tree
+	) > current &&
+	cat >expected <<\EOF &&
+100644 blob X	1.txt
+100644 blob X	2.txt
+040000 tree X	path0
+040000 tree X	path1
+040000 tree X	path2
+040000 tree X	path3
+EOF
+	test_output
+'
+
+test_expect_success 'ls-tree --full-tree -r' '
+	(
+		cd path3/ &&
+		git ls-tree --full-tree -r $tree
+	) > current &&
+	cat >expected <<\EOF &&
+100644 blob X	1.txt
+100644 blob X	2.txt
+100644 blob X	path0/a/b/c/1.txt
+100644 blob X	path1/b/c/1.txt
+100644 blob X	path2/1.txt
+100644 blob X	path3/1.txt
+100644 blob X	path3/2.txt
+EOF
+	test_output
+'
+
+test_expect_success 'ls-tree --abbrev=5' '
+	git ls-tree --abbrev=5 $tree > current.abbrev &&
+	sed -e "s/ $_x5	/ X	/"  < current.abbrev > current &&
+	cat >expected <<\EOF &&
+100644 blob X	1.txt
+100644 blob X	2.txt
+040000 tree X	path0
+040000 tree X	path1
+040000 tree X	path2
+040000 tree X	path3
+EOF
+	test_output
+'
+
+test_expect_success 'ls-tree --name-only' '
+	git ls-tree --name-only $tree > current
+	cat >expected <<\EOF &&
+1.txt
+2.txt
+path0
+path1
+path2
+path3
+EOF
+	test_output
+'
+
+test_expect_success 'ls-tree --name-only -r' '
+	git ls-tree --name-only -r $tree > current
+	cat >expected <<\EOF &&
+1.txt
+2.txt
+path0/a/b/c/1.txt
+path1/b/c/1.txt
+path2/1.txt
+path3/1.txt
+path3/2.txt
+EOF
+	test_output
+'
+
 test_done
-- 
1.6.5.2.155.gbb47
Previous: Stephen BoydNext: Junio C Hamano
Message 2 of 10 in “Migrate ls-tree to parse-opts”
  1. 0/2 Migrate ls-tree to parse-optsStephen Boyd, Nov 14, 2009
  2. 1/2 t3101: test more ls-tree optionsStephen Boyd, Nov 14, 2009
  3. Junio C HamanoNov 17, 2009
  4. Stephen BoydNov 17, 2009
  5. 2/2 ls-tree: migrate to parse-optionsStephen Boyd, Nov 14, 2009
  6. Junio C HamanoNov 17, 2009
  7. Stephen BoydNov 17, 2009
  8. Stephen BoydNov 17, 2009
  9. Junio C HamanoNov 18, 2009
  10. Thiago FarinaNov 18, 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.