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

[PATCH v4 1/4] test-lib.sh: introduce and use $EMPTY_TREE

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 16, 2016, 05:06 UTC
Message-ID
<20160716050627.9416-2-pclouds@gmail.com>
In-Reply-To
<20160716050627.9416-1-pclouds@gmail.com>

This is a special SHA1. Let's keep it at one place, easier to replace later when the hash change comes, easier to recognize.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t0000-basic.sh                |  2 +-
 t/t1100-commit-tree-options.sh  |  2 +-
 t/t4010-diff-pathspec.sh        |  2 --
 t/t4054-diff-bogus-tree.sh      | 10 ++++------
 t/t5504-fetch-receive-strict.sh |  4 ++--
 t/test-lib.sh                   |  4 +++-
 6 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 60811a3..1aa5093 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -834,7 +834,7 @@ test_expect_success 'git write-tree should be able to write an empty tree' '
 '
 
 test_expect_success 'validate object ID of a known tree' '
-	test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904
+	test "$tree" = $EMPTY_TREE
 '
 
 # Various types of objects
diff --git a/t/t1100-commit-tree-options.sh b/t/t1100-commit-tree-options.sh
index b7e9b4fc..ae66ba5 100755
--- a/t/t1100-commit-tree-options.sh
+++ b/t/t1100-commit-tree-options.sh
@@ -15,7 +15,7 @@ Also make sure that command line parser understands the normal
 . ./test-lib.sh
 
 cat >expected <<EOF
-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
+tree $EMPTY_TREE
 author Author Name <author@email> 1117148400 +0000
 committer Committer Name <committer@email> 1117150200 +0000
 
diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index 43c488b..35b35a8 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -78,8 +78,6 @@ test_expect_success 'diff-tree pathspec' '
 	test_cmp expected current
 '
 
-EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
-
 test_expect_success 'diff-tree with wildcard shows dir also matches' '
 	git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
 	echo file0 >expected &&
diff --git a/t/t4054-diff-bogus-tree.sh b/t/t4054-diff-bogus-tree.sh
index 1d6efab..18f42c5 100755
--- a/t/t4054-diff-bogus-tree.sh
+++ b/t/t4054-diff-bogus-tree.sh
@@ -3,8 +3,6 @@
 test_description='test diff with a bogus tree containing the null sha1'
 . ./test-lib.sh
 
-empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
-
 test_expect_success 'create bogus tree' '
 	bogus_tree=$(
 		printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
@@ -22,13 +20,13 @@ test_expect_success 'create tree with matching file' '
 
 test_expect_success 'raw diff shows null sha1 (addition)' '
 	echo ":000000 100644 $_z40 $_z40 A	foo" >expect &&
-	git diff-tree $empty_tree $bogus_tree >actual &&
+	git diff-tree $EMPTY_TREE $bogus_tree >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (removal)' '
 	echo ":100644 000000 $_z40 $_z40 D	foo" >expect &&
-	git diff-tree $bogus_tree $empty_tree >actual &&
+	git diff-tree $bogus_tree $EMPTY_TREE >actual &&
 	test_cmp expect actual
 '
 
@@ -57,11 +55,11 @@ test_expect_success 'raw diff shows null sha1 (index)' '
 '
 
 test_expect_success 'patch fails due to bogus sha1 (addition)' '
-	test_must_fail git diff-tree -p $empty_tree $bogus_tree
+	test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
 '
 
 test_expect_success 'patch fails due to bogus sha1 (removal)' '
-	test_must_fail git diff-tree -p $bogus_tree $empty_tree
+	test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
 '
 
 test_expect_success 'patch fails due to bogus sha1 (modification)' '
diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh
index 44f3d5f..9b19cff 100755
--- a/t/t5504-fetch-receive-strict.sh
+++ b/t/t5504-fetch-receive-strict.sh
@@ -115,8 +115,8 @@ test_expect_success 'push with transfer.fsckobjects' '
 	test_cmp exp act
 '
 
-cat >bogus-commit <<\EOF
-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
+cat >bogus-commit <<EOF
+tree $EMPTY_TREE
 author Bugs Bunny 1234567890 +0000
 committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0055ebb..85f4c6d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -162,6 +162,8 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
 # Zero SHA-1
 _z40=0000000000000000000000000000000000000000
 
+EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+
 # Line feed
 LF='
 '
@@ -170,7 +172,7 @@ LF='
 # when case-folding filenames
 u200c=$(printf '\342\200\214')
 
-export _x05 _x40 _z40 LF u200c
+export _x05 _x40 _z40 LF u200c EMPTY_TREE
 
 # Each test should start with something like this, after copyright notices:
 #
-- 
2.9.1.566.gbd532d4
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 26 of 30 in “Git doesn't always add files to a commit (amend)”
  1. Yuri KanivetskyJul 4, 2016
  2. Duy NguyenJul 4, 2016
  3. cache-tree.c: fix i-t-a check skipping directory updates sometimesNguyễn Thái Ngọc Duy, Jul 4, 2016
  4. Junio C HamanoJul 6, 2016
  5. Junio C HamanoJul 6, 2016
  6. 0/2 cache-tree building fix in the presence of ita entriesNguyễn Thái Ngọc Duy, Jul 6, 2016
  7. 1/2 cache-tree.c: fix i-t-a entry skipping directory updates sometimesNguyễn Thái Ngọc Duy, Jul 6, 2016
  8. 2/2 cache-tree: do not generate empty trees as a result of all i-t-a subentriesNguyễn Thái Ngọc Duy, Jul 6, 2016
  9. Junio C HamanoJul 6, 2016
  10. Duy NguyenJul 7, 2016
  11. Junio C HamanoJul 7, 2016
  12. Duy NguyenJul 8, 2016
  13. Junio C HamanoJul 8, 2016
  14. Duy NguyenJul 8, 2016
  15. Junio C HamanoJul 8, 2016
  16. 0/4 cache-tree building fix in the presence of ita entriesNguyễn Thái Ngọc Duy, Jul 9, 2016
  17. 2/4 test-lib.sh: introduce and use $_EMPTY_BLOBNguyễn Thái Ngọc Duy, Jul 9, 2016
  18. 3/4 cache-tree.c: fix i-t-a entry skipping directory updates sometimesNguyễn Thái Ngọc Duy, Jul 9, 2016
  19. 4/4 cache-tree: do not generate empty trees as a result of all i-t-a subentriesNguyễn Thái Ngọc Duy, Jul 9, 2016
  20. Junio C HamanoJul 12, 2016
  21. Duy NguyenJul 13, 2016
  22. 1/4 test-lib.sh: introduce and use $_EMPTY_TREENguyễn Thái Ngọc Duy, Jul 9, 2016
  23. Junio C HamanoJul 12, 2016
  24. Duy NguyenJul 13, 2016
  25. 0/4 cache-tree building fix in the presence of ita entriesNguyễn Thái Ngọc Duy, Jul 16, 2016
  26. 1/4 test-lib.sh: introduce and use $EMPTY_TREENguyễn Thái Ngọc Duy, Jul 16, 2016
  27. 3/4 cache-tree.c: fix i-t-a entry skipping directory updates sometimesNguyễn Thái Ngọc Duy, Jul 16, 2016
  28. 4/4 cache-tree: do not generate empty trees as a result of all i-t-a subentriesNguyễn Thái Ngọc Duy, Jul 16, 2016
  29. 2/4 test-lib.sh: introduce and use $EMPTY_BLOBNguyễn Thái Ngọc Duy, Jul 16, 2016
  30. Junio C HamanoJul 18, 2016

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.