Re: [PATCH v3 1/4] test-lib.sh: introduce and use $_EMPTY_TREE

2016-07-13 Thread Duy Nguyen
On Tue, Jul 12, 2016 at 10:40 PM, Junio C Hamano  wrote:
> Nguyễn Thái Ngọc Duy   writes:
>
>> This is a special SHA1. Let's keep it at one place, easier to replace
>> later when the hash change comes, easier to recognize. Start with an
>> underscore to reduce the chances somebody may override it without
>> realizing it's predefined.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy 
>> ---
>>  t/t-basic.sh|  2 +-
>>  t/t1100-commit-tree-options.sh  |  2 +-
>>  t/t4010-diff-pathspec.sh|  6 ++
>>  t/t4054-diff-bogus-tree.sh  | 10 --
>>  t/t5504-fetch-receive-strict.sh |  4 ++--
>>  t/test-lib.sh   |  4 +++-
>>  6 files changed, 13 insertions(+), 15 deletions(-)
>>
>> diff --git a/t/t-basic.sh b/t/t-basic.sh
>> index 60811a3..48214e9 100755
>> --- a/t/t-basic.sh
>> +++ b/t/t-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
>>  '
>
> I doubt the point of, and I'd rather not to see, the leading
> underscore.  Are there existing uses of the name that want it to
> mean something different?

No. There is EMPTY_TREE in use, but it's exactly what we expect. It's
probably still a good idea to separate "global" variables from
per-file ones. But I don't feel strongly about this, so if a re-roll
is required (or somebody votes for underscore removal, including you),
I'll remove the underscore.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/4] test-lib.sh: introduce and use $_EMPTY_TREE

2016-07-12 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy   writes:

> This is a special SHA1. Let's keep it at one place, easier to replace
> later when the hash change comes, easier to recognize. Start with an
> underscore to reduce the chances somebody may override it without
> realizing it's predefined.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy 
> ---
>  t/t-basic.sh|  2 +-
>  t/t1100-commit-tree-options.sh  |  2 +-
>  t/t4010-diff-pathspec.sh|  6 ++
>  t/t4054-diff-bogus-tree.sh  | 10 --
>  t/t5504-fetch-receive-strict.sh |  4 ++--
>  t/test-lib.sh   |  4 +++-
>  6 files changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/t/t-basic.sh b/t/t-basic.sh
> index 60811a3..48214e9 100755
> --- a/t/t-basic.sh
> +++ b/t/t-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
>  '

I doubt the point of, and I'd rather not to see, the leading
underscore.  Are there existing uses of the name that want it to
mean something different?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2016-07-08 Thread Nguyễn Thái Ngọc Duy
This is a special SHA1. Let's keep it at one place, easier to replace
later when the hash change comes, easier to recognize. Start with an
underscore to reduce the chances somebody may override it without
realizing it's predefined.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 t/t-basic.sh|  2 +-
 t/t1100-commit-tree-options.sh  |  2 +-
 t/t4010-diff-pathspec.sh|  6 ++
 t/t4054-diff-bogus-tree.sh  | 10 --
 t/t5504-fetch-receive-strict.sh |  4 ++--
 t/test-lib.sh   |  4 +++-
 6 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/t/t-basic.sh b/t/t-basic.sh
index 60811a3..48214e9 100755
--- a/t/t-basic.sh
+++ b/t/t-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..2adb123 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 < 1117148400 +
 committer Committer Name  1117150200 +
 
diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index 43c488b..7c98912 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -78,16 +78,14 @@ 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 &&
+   git diff-tree --name-only $_EMPTY_TREE $tree -- "f*" >result &&
echo file0 >expected &&
test_cmp expected result
 '
 
 test_expect_success 'diff-tree -r with wildcard' '
-   git diff-tree -r --name-only $EMPTY_TREE $tree -- "*file1" >result &&
+   git diff-tree -r --name-only $_EMPTY_TREE $tree -- "*file1" >result &&
echo path1/file1 >expected &&
test_cmp expected result
 '
diff --git a/t/t4054-diff-bogus-tree.sh b/t/t4054-diff-bogus-tree.sh
index 1d6efab..6b48512 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 fooQ" |
@@ -22,13 +20,13 @@ test_expect_success 'create tree with matching file' '
 
 test_expect_success 'raw diff shows null sha1 (addition)' '
echo ":00 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 00 $_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..39cc971 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 < 1234567890 +
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0055ebb..327caa5 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=
 
+_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.8.2.537.g0965dd9

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.o