threads / patch / 66925

patcht1501: don't reassign EMPTY_BLOB and EMPTY_TREE

Subject: [PATCH] t1501: don't reassign EMPTY_BLOB and EMPTY_TREE

## tl;dr

4 messages between Nov 24, 2026 and Nov 25, 2026. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

René Scharfe· Nov 24, 2026, 09:15 UTC · lore

The variables EMPTY_BLOB AND EMPTY_TREE are already set by test-lib.sh, so just use them.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 t/t1501-work-tree.sh | 2 --
 1 file changed, 2 deletions(-)
Show changes to t/t1501-work-tree.sh +0 −2
diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
index 8c94ac2e70..e6f43b0fb8 100755
--- a/t/t1501-work-tree.sh
+++ b/t/t1501-work-tree.sh
@@ -5,8 +5,6 @@ test_description='test separate work tree'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-	EMPTY_TREE=$(git write-tree) &&
-	EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) &&
 	CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) &&
 	EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") &&
 	CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") &&
-- 
2.56.1
Ben Knoble· Nov 24, 2026, 12:51 UTC · re: René Scharfe · lore

Re: [PATCH] t1501: don't reassign EMPTY_BLOB and EMPTY_TREE

> Le 24 nov. 2026 à 04:16, René Scharfe <l.s.r@web.de> a écrit :
> 
> The variables EMPTY_BLOB AND EMPTY_TREE are already set by test-lib.sh,
> so just use them.
Nit: downcase and?
Show 21 quoted lines
> 
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> t/t1501-work-tree.sh | 2 --
> 1 file changed, 2 deletions(-)
> 
> diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
> index 8c94ac2e70..e6f43b0fb8 100755
> --- a/t/t1501-work-tree.sh
> +++ b/t/t1501-work-tree.sh
> @@ -5,8 +5,6 @@ test_description='test separate work tree'
> . ./test-lib.sh
> 
> test_expect_success 'setup' '
> -    EMPTY_TREE=$(git write-tree) &&
> -    EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) &&
>    CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) &&
>    EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") &&
>    CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") &&
> --
> 2.56.1

Nice simplification. A future reader may wonder what sets those, but git-grep turns them up.

René Scharfe· Nov 25, 2026, 11:39 UTC · re: Ben Knoble · lore

Re: [PATCH] t1501: don't reassign EMPTY_BLOB and EMPTY_TREE

On 11/24/26 1:51 PM, Ben Knoble wrote:
Show 7 quoted lines
> 
>> Le 24 nov. 2026 à 04:16, René Scharfe <l.s.r@web.de> a écrit :
>>
>> The variables EMPTY_BLOB AND EMPTY_TREE are already set by test-lib.sh,
>> so just use them.
> 
> Nit: downcase and?
Right, no need to shout the conjunction..
René
Junio C Hamano· Nov 24, 2026, 20:29 UTC · re: René Scharfe · lore

Re: [PATCH] t1501: don't reassign EMPTY_BLOB and EMPTY_TREE

René Scharfe <l.s.r@web.de> writes:
Show 7 quoted lines
> The variables EMPTY_BLOB AND EMPTY_TREE are already set by test-lib.sh,
> so just use them.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  t/t1501-work-tree.sh | 2 --
>  1 file changed, 2 deletions(-)

Nice spotting. Even though the version in test-lib.sh has a certain "Yuck" factor by relying on hardcoded values in oid-info/hash-info file, we already rely on them everywhere, so there is no good excuse not to use them.

Will queue.  Thanks.
Show 13 quoted lines
> diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
> index 8c94ac2e70..e6f43b0fb8 100755
> --- a/t/t1501-work-tree.sh
> +++ b/t/t1501-work-tree.sh
> @@ -5,8 +5,6 @@ test_description='test separate work tree'
>  . ./test-lib.sh
>  
>  test_expect_success 'setup' '
> -	EMPTY_TREE=$(git write-tree) &&
> -	EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) &&
>  	CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) &&
>  	EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") &&
>  	CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") &&

← back to recent threads