git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] t: make many tests depend less on the refs being files
@ 2018-05-21  5:51 Christian Couder
  2018-05-21  9:41 ` Johannes Schindelin
  2018-05-21 19:34 ` Stefan Beller
  0 siblings, 2 replies; 8+ messages in thread
From: Christian Couder @ 2018-05-21  5:51 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Stefan Beller, Jonathan Nieder, Jonathan Tan, Duy Nguyen,
	Derrick Stolee, Carlos Martín Nieto, Michael Haggerty,
	David Turner, Christian Couder, David Turner

From: David Turner <dturner@twopensource.com>

So that they work under alternate ref storage backends.

This will be really needed when such alternate ref storage backends are
developed. But this could already help by making clear to readers that
some tests do not depend on which ref backend is used.

This patch just takes care of many low hanging fruits. It does not try
to completely solves the issue.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---

Thanks for all the great feedback regarding implementing reftable [1].

Looking at David Turner's tests in [2], it seems that they could indeed
be already valuable, so let's start by extracting most of the simple
improvements they make. 

[1] https://public-inbox.org/git/CAP8UFD0PPZSjBnxCA7ez91vBuatcHKQ+JUWvTD1iHcXzPBjPBg@mail.gmail.com/
[2] https://github.com/dturner-tw/git/tree/dturner/pluggable-backends

 t/lib-t6000.sh                   |  5 ++---
 t/t1401-symbolic-ref.sh          |  2 +-
 t/t3200-branch.sh                | 18 +++++++++---------
 t/t3903-stash.sh                 |  2 +-
 t/t5500-fetch-pack.sh            | 10 +++++-----
 t/t5510-fetch.sh                 |  6 +++---
 t/t6010-merge-base.sh            |  2 +-
 t/t7201-co.sh                    |  2 +-
 t/t9104-git-svn-follow-parent.sh |  3 ++-
 t/t9903-bash-prompt.sh           |  2 +-
 10 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
index 3f2d873fec..b8567cdf94 100644
--- a/t/lib-t6000.sh
+++ b/t/lib-t6000.sh
@@ -4,11 +4,10 @@ mkdir -p .git/refs/tags
 
 >sed.script
 
-# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
+# Answer the sha1 has associated with the tag. The tag must exist under refs/tags
 tag () {
 	_tag=$1
-	test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
-	cat ".git/refs/tags/$_tag"
+	git rev-parse --verify "refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
 }
 
 # Generate a commit using the text specified to make it unique and the tree
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
index 9e782a8122..a4ebb0b65f 100755
--- a/t/t1401-symbolic-ref.sh
+++ b/t/t1401-symbolic-ref.sh
@@ -65,7 +65,7 @@ reset_to_sane
 test_expect_success 'symbolic-ref fails to delete real ref' '
 	echo "fatal: Cannot delete refs/heads/foo, not a symbolic ref" >expect &&
 	test_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&
-	test_path_is_file .git/refs/heads/foo &&
+	git rev-parse --verify refs/heads/foo &&
 	test_cmp expect actual
 '
 reset_to_sane
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c0ef946811..222dc2c377 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -234,34 +234,34 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch
 
 test_expect_success 'git branch -v -d t should work' '
 	git branch t &&
-	test_path_is_file .git/refs/heads/t &&
+	git rev-parse --verify refs/heads/t &&
 	git branch -v -d t &&
-	test_path_is_missing .git/refs/heads/t
+	test_must_fail git rev-parse --verify refs/heads/t
 '
 
 test_expect_success 'git branch -v -m t s should work' '
 	git branch t &&
-	test_path_is_file .git/refs/heads/t &&
+	git rev-parse --verify refs/heads/t &&
 	git branch -v -m t s &&
-	test_path_is_missing .git/refs/heads/t &&
-	test_path_is_file .git/refs/heads/s &&
+	test_must_fail git rev-parse --verify refs/heads/t &&
+	git rev-parse --verify refs/heads/s &&
 	git branch -d s
 '
 
 test_expect_success 'git branch -m -d t s should fail' '
 	git branch t &&
-	test_path_is_file .git/refs/heads/t &&
+	git rev-parse refs/heads/t &&
 	test_must_fail git branch -m -d t s &&
 	git branch -d t &&
-	test_path_is_missing .git/refs/heads/t
+	test_must_fail git rev-parse refs/heads/t
 '
 
 test_expect_success 'git branch --list -d t should fail' '
 	git branch t &&
-	test_path_is_file .git/refs/heads/t &&
+	git rev-parse refs/heads/t &&
 	test_must_fail git branch --list -d t &&
 	git branch -d t &&
-	test_path_is_missing .git/refs/heads/t
+	test_must_fail git rev-parse refs/heads/t
 '
 
 test_expect_success 'git branch --list -v with --abbrev' '
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index aefde7b172..1f871d3cca 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -726,7 +726,7 @@ test_expect_success 'store updates stash ref and reflog' '
 	git reset --hard &&
 	! grep quux bazzy &&
 	git stash store -m quuxery $STASH_ID &&
-	test $(cat .git/refs/stash) = $STASH_ID &&
+	test $(git rev-parse stash) = $STASH_ID &&
 	git reflog --format=%H stash| grep $STASH_ID &&
 	git stash pop &&
 	grep quux bazzy
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 0680dec808..886a9e3b72 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -30,7 +30,7 @@ add () {
 	test_tick &&
 	commit=$(echo "$text" | git commit-tree $tree $parents) &&
 	eval "$name=$commit; export $name" &&
-	echo $commit > .git/refs/heads/$branch &&
+	git update-ref refs/heads/$branch $commit &&
 	eval ${branch}TIP=$commit
 }
 
@@ -45,10 +45,10 @@ pull_to_client () {
 
 			case "$heads" in
 			    *A*)
-				    echo $ATIP > .git/refs/heads/A;;
+				    git update-ref refs/heads/A $ATIP;;
 			esac &&
 			case "$heads" in *B*)
-			    echo $BTIP > .git/refs/heads/B;;
+			    git update-ref refs/heads/B $BTIP;;
 			esac &&
 			git symbolic-ref HEAD refs/heads/$(echo $heads \
 				| sed -e "s/^\(.\).*$/\1/") &&
@@ -92,8 +92,8 @@ test_expect_success 'setup' '
 		cur=$(($cur+1))
 	done &&
 	add B1 $A1 &&
-	echo $ATIP > .git/refs/heads/A &&
-	echo $BTIP > .git/refs/heads/B &&
+	git update-ref refs/heads/A $ATIP &&
+	git update-ref refs/heads/B $BTIP &&
 	git symbolic-ref HEAD refs/heads/B
 '
 
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ae5a530a2d..e402aee6a2 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -63,7 +63,7 @@ test_expect_success "fetch test" '
 	git commit -a -m "updated by origin" &&
 	cd two &&
 	git fetch &&
-	test -f .git/refs/heads/one &&
+	git rev-parse --verify refs/heads/one &&
 	mine=$(git rev-parse refs/heads/one) &&
 	his=$(cd ../one && git rev-parse refs/heads/master) &&
 	test "z$mine" = "z$his"
@@ -73,8 +73,8 @@ test_expect_success "fetch test for-merge" '
 	cd "$D" &&
 	cd three &&
 	git fetch &&
-	test -f .git/refs/heads/two &&
-	test -f .git/refs/heads/one &&
+	git rev-parse --verify refs/heads/two &&
+	git rev-parse --verify refs/heads/one &&
 	master_in_two=$(cd ../two && git rev-parse master) &&
 	one_in_two=$(cd ../two && git rev-parse one) &&
 	{
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index 31db7b5f91..56c4d91812 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -34,7 +34,7 @@ doit () {
 
 	commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
 
-	echo $commit >.git/refs/tags/$NAME &&
+	git update-ref refs/tags/$NAME $commit &&
 	echo $commit
 }
 
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 76c223c967..ab9da61da3 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -65,7 +65,7 @@ test_expect_success setup '
 test_expect_success "checkout from non-existing branch" '
 
 	git checkout -b delete-me master &&
-	rm .git/refs/heads/delete-me &&
+	git update-ref -d --no-deref refs/heads/delete-me &&
 	test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
 	git checkout master &&
 	test refs/heads/master = "$(git symbolic-ref HEAD)"
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index a735fa3717..9c49b6c1fe 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -215,7 +215,8 @@ test_expect_success "multi-fetch continues to work" "
 	"
 
 test_expect_success "multi-fetch works off a 'clean' repository" '
-	rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
+	rm -rf "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" &&
+	git reflog expire --all --expire=all &&
 	mkdir "$GIT_DIR/svn" &&
 	git svn multi-fetch
 	'
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 8f5c811dd7..c3b89ae783 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
 test_expect_success 'prompt - deep inside .git directory' '
 	printf " (GIT_DIR!)" >expected &&
 	(
-		cd .git/refs/heads &&
+		cd .git/objects &&
 		__git_ps1 >"$actual"
 	) &&
 	test_cmp expected "$actual"
-- 
2.17.0.582.gccdcbd54c4.dirty


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21  5:51 [PATCH] t: make many tests depend less on the refs being files Christian Couder
@ 2018-05-21  9:41 ` Johannes Schindelin
  2018-05-21 11:49   ` SZEDER Gábor
                     ` (2 more replies)
  2018-05-21 19:34 ` Stefan Beller
  1 sibling, 3 replies; 8+ messages in thread
From: Johannes Schindelin @ 2018-05-21  9:41 UTC (permalink / raw)
  To: Christian Couder
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Stefan Beller, Jonathan Nieder, Jonathan Tan, Duy Nguyen,
	Derrick Stolee, Carlos Martín Nieto, Michael Haggerty,
	David Turner, Christian Couder, David Turner

[-- Attachment #1: Type: text/plain, Size: 3645 bytes --]

Hi Chris,

On Mon, 21 May 2018, Christian Couder wrote:

> From: David Turner <dturner@twopensource.com>

I vaguely remember that Dave suggested using a different email address
these days...

*clicketyclick*

ah, yes:
https://public-inbox.org/git/1474935093-26757-3-git-send-email-dturner@twosigma.com/

So maybe update it here, too, to 

	From: David Turner <novalis@novalis.org>

?

> So that they work under alternate ref storage backends.
> 
> This will be really needed when such alternate ref storage backends are
> developed. But this could already help by making clear to readers that
> some tests do not depend on which ref backend is used.
> 
> This patch just takes care of many low hanging fruits. It does not try
> to completely solves the issue.
> 
> Signed-off-by: David Turner <dturner@twopensource.com>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---

This is great. I am all for making the tests better ;-)

> diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
> index 3f2d873fec..b8567cdf94 100644
> --- a/t/lib-t6000.sh
> +++ b/t/lib-t6000.sh
> @@ -4,11 +4,10 @@ mkdir -p .git/refs/tags
>  
>  >sed.script
>  
> -# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
> +# Answer the sha1 has associated with the tag. The tag must exist under refs/tags
>  tag () {
>  	_tag=$1
> -	test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
> -	cat ".git/refs/tags/$_tag"
> +	git rev-parse --verify "refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"

Line longer than 80 columns...

> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> index 0680dec808..886a9e3b72 100755
> --- a/t/t5500-fetch-pack.sh
> +++ b/t/t5500-fetch-pack.sh
> @@ -30,7 +30,7 @@ add () {
>  	test_tick &&
>  	commit=$(echo "$text" | git commit-tree $tree $parents) &&
>  	eval "$name=$commit; export $name" &&
> -	echo $commit > .git/refs/heads/$branch &&
> +	git update-ref refs/heads/$branch $commit &&

I think we have to be careful here to quote both "refs/heads/$branch" and
"$commit" here, as a bug that introduces spaces into $commit or $branch
would have been caught earlier, but not now, unless we quote.

This goes for all introduced `update-ref` calls.

Maybe even for some `git rev-parse --verify` calls.

> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> index 8f5c811dd7..c3b89ae783 100755
> --- a/t/t9903-bash-prompt.sh
> +++ b/t/t9903-bash-prompt.sh
> @@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
>  test_expect_success 'prompt - deep inside .git directory' '
>  	printf " (GIT_DIR!)" >expected &&
>  	(
> -		cd .git/refs/heads &&
> +		cd .git/objects &&
>  		__git_ps1 >"$actual"
>  	) &&
>  	test_cmp expected "$actual"
> -- 

This one looks wrong.

Upon cursory review, one might be tempted to assume that the file is now
written into .git/objects/ instead of .git/refs/heads/. And the patch
context provided in the email is not enough to see (gawd, I hate
mail-based patch review, it really takes all my Git tools away from me).
The trick is that `actual` points at an absolute path:

	#!/bin/sh
	#
	# Copyright (c) 2012 SZEDER Gábor
	#

	test_description='test git-specific bash prompt functions'

	. ./lib-bash.sh

	. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"

	actual="$TRASH_DIRECTORY/actual"
	[...]

So the remaining question (which probably wants to be added to the commit
message together with a hint that `actual` points at an absolute path) is:
Why not `cd .git` instead?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21  9:41 ` Johannes Schindelin
@ 2018-05-21 11:49   ` SZEDER Gábor
  2018-05-23  5:27     ` Christian Couder
  2018-05-21 12:30   ` Christian Couder
  2018-05-21 12:37   ` Johannes Schindelin
  2 siblings, 1 reply; 8+ messages in thread
From: SZEDER Gábor @ 2018-05-21 11:49 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: SZEDER Gábor, Christian Couder, git, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Stefan Beller,
	Jonathan Nieder, Jonathan Tan, Duy Nguyen, Derrick Stolee,
	Carlos Martín Nieto, Michael Haggerty, David Turner,
	Christian Couder, David Turner

> > diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> > index 8f5c811dd7..c3b89ae783 100755
> > --- a/t/t9903-bash-prompt.sh
> > +++ b/t/t9903-bash-prompt.sh
> > @@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
> >  test_expect_success 'prompt - deep inside .git directory' '
> >  	printf " (GIT_DIR!)" >expected &&
> >  	(
> > -		cd .git/refs/heads &&
> > +		cd .git/objects &&
> >  		__git_ps1 >"$actual"
> >  	) &&
> >  	test_cmp expected "$actual"
> 
> This one looks wrong.

It's right, though.

> Why not `cd .git` instead?

That case is covered in the previous test.

Once upon a time it mattered how deep we were in the .git directory
when running __git_ps1(), because it executed different branches of a
long-ish if-elif chain.  For the prompt it doesn't matter anymore,
because those ifs were eliminated, but for the completion script it
still does, which brings us to:

Christian!  There is a similar test, '__git_find_repo_path - parent is
a .git directory' in 't9902-completion.sh', which, too, performs a 'cd
.git/refs/heads'.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21  9:41 ` Johannes Schindelin
  2018-05-21 11:49   ` SZEDER Gábor
@ 2018-05-21 12:30   ` Christian Couder
  2018-05-21 12:37   ` Johannes Schindelin
  2 siblings, 0 replies; 8+ messages in thread
From: Christian Couder @ 2018-05-21 12:30 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Stefan Beller, Jonathan Nieder, Jonathan Tan, Duy Nguyen,
	Derrick Stolee, Carlos Martín Nieto, Michael Haggerty,
	David Turner, Christian Couder, David Turner

Hi Dscho,

On Mon, May 21, 2018 at 11:41 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> On Mon, 21 May 2018, Christian Couder wrote:
>
>> From: David Turner <dturner@twopensource.com>
>
> I vaguely remember that Dave suggested using a different email address
> these days...
>
> *clicketyclick*
>
> ah, yes:
> https://public-inbox.org/git/1474935093-26757-3-git-send-email-dturner@twosigma.com/

Yeah, I actually used "David Turner <novalis@novalis.org>" in the --cc
option I gave to `git send-email`...

> So maybe update it here, too, to
>
>         From: David Turner <novalis@novalis.org>

...but I thought it was better to keep the original author and
Signed-off-by as they are in the original commit:

https://github.com/dturner-tw/git/commit/0a3fa7fbd7f99280b5f128be3e1ed04e045da671

Now I am ok to update them if it is preferred.

>> So that they work under alternate ref storage backends.
>>
>> This will be really needed when such alternate ref storage backends are
>> developed. But this could already help by making clear to readers that
>> some tests do not depend on which ref backend is used.
>>
>> This patch just takes care of many low hanging fruits. It does not try
>> to completely solves the issue.
>>
>> Signed-off-by: David Turner <dturner@twopensource.com>
>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>> ---
>
> This is great. I am all for making the tests better ;-)

;-)

>> diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
>> index 3f2d873fec..b8567cdf94 100644
>> --- a/t/lib-t6000.sh
>> +++ b/t/lib-t6000.sh
>> @@ -4,11 +4,10 @@ mkdir -p .git/refs/tags
>>
>>  >sed.script
>>
>> -# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
>> +# Answer the sha1 has associated with the tag. The tag must exist under refs/tags
>>  tag () {
>>       _tag=$1
>> -     test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
>> -     cat ".git/refs/tags/$_tag"
>> +     git rev-parse --verify "refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
>
> Line longer than 80 columns...

Ok, the 'error "..."' will be on another line in the next version.

>> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
>> index 0680dec808..886a9e3b72 100755
>> --- a/t/t5500-fetch-pack.sh
>> +++ b/t/t5500-fetch-pack.sh
>> @@ -30,7 +30,7 @@ add () {
>>       test_tick &&
>>       commit=$(echo "$text" | git commit-tree $tree $parents) &&
>>       eval "$name=$commit; export $name" &&
>> -     echo $commit > .git/refs/heads/$branch &&
>> +     git update-ref refs/heads/$branch $commit &&
>
> I think we have to be careful here to quote both "refs/heads/$branch" and
> "$commit" here, as a bug that introduces spaces into $commit or $branch
> would have been caught earlier, but not now, unless we quote.
>
> This goes for all introduced `update-ref` calls.

Ok, they will all have quoted arguments in the next version.

> Maybe even for some `git rev-parse --verify` calls.

Ok, I will take a look at that.

>> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
>> index 8f5c811dd7..c3b89ae783 100755
>> --- a/t/t9903-bash-prompt.sh
>> +++ b/t/t9903-bash-prompt.sh
>> @@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
>>  test_expect_success 'prompt - deep inside .git directory' '
>>       printf " (GIT_DIR!)" >expected &&
>>       (
>> -             cd .git/refs/heads &&
>> +             cd .git/objects &&
>>               __git_ps1 >"$actual"
>>       ) &&
>>       test_cmp expected "$actual"
>> --
>
> This one looks wrong.
>
> Upon cursory review, one might be tempted to assume that the file is now
> written into .git/objects/ instead of .git/refs/heads/. And the patch
> context provided in the email is not enough to see (gawd, I hate
> mail-based patch review, it really takes all my Git tools away from me).
> The trick is that `actual` points at an absolute path:
>
>         #!/bin/sh
>         #
>         # Copyright (c) 2012 SZEDER Gábor
>         #
>
>         test_description='test git-specific bash prompt functions'
>
>         . ./lib-bash.sh
>
>         . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
>
>         actual="$TRASH_DIRECTORY/actual"
>         [...]
>
> So the remaining question (which probably wants to be added to the commit
> message together with a hint that `actual` points at an absolute path) is:
> Why not `cd .git` instead?

I think anywhere inside ".git/" should work, so I guess
".git/refs/heads" was chosen to make sure that adding anything after
".git/" does not change the result.

I think I can drop this for now and change it later in its own commit
with related explanations.

Thanks,
Christian.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21  9:41 ` Johannes Schindelin
  2018-05-21 11:49   ` SZEDER Gábor
  2018-05-21 12:30   ` Christian Couder
@ 2018-05-21 12:37   ` Johannes Schindelin
  2 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2018-05-21 12:37 UTC (permalink / raw)
  To: Christian Couder
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Stefan Beller, Jonathan Nieder, Jonathan Tan, Duy Nguyen,
	Derrick Stolee, Carlos Martín Nieto, Michael Haggerty,
	David Turner, Christian Couder

[-- Attachment #1: Type: text/plain, Size: 4006 bytes --]

Hi,

of course I messed up and did not fix the Cc: list... now fixed ;-)


On Mon, 21 May 2018, Johannes Schindelin wrote:

> Hi Chris,
> 
> On Mon, 21 May 2018, Christian Couder wrote:
> 
> > From: David Turner <dturner@twopensource.com>
> 
> I vaguely remember that Dave suggested using a different email address
> these days...
> 
> *clicketyclick*
> 
> ah, yes:
> https://public-inbox.org/git/1474935093-26757-3-git-send-email-dturner@twosigma.com/
> 
> So maybe update it here, too, to 
> 
> 	From: David Turner <novalis@novalis.org>
> 
> ?
> 
> > So that they work under alternate ref storage backends.
> > 
> > This will be really needed when such alternate ref storage backends are
> > developed. But this could already help by making clear to readers that
> > some tests do not depend on which ref backend is used.
> > 
> > This patch just takes care of many low hanging fruits. It does not try
> > to completely solves the issue.
> > 
> > Signed-off-by: David Turner <dturner@twopensource.com>
> > Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> > ---
> 
> This is great. I am all for making the tests better ;-)
> 
> > diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
> > index 3f2d873fec..b8567cdf94 100644
> > --- a/t/lib-t6000.sh
> > +++ b/t/lib-t6000.sh
> > @@ -4,11 +4,10 @@ mkdir -p .git/refs/tags
> >  
> >  >sed.script
> >  
> > -# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
> > +# Answer the sha1 has associated with the tag. The tag must exist under refs/tags
> >  tag () {
> >  	_tag=$1
> > -	test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
> > -	cat ".git/refs/tags/$_tag"
> > +	git rev-parse --verify "refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
> 
> Line longer than 80 columns...
> 
> > diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> > index 0680dec808..886a9e3b72 100755
> > --- a/t/t5500-fetch-pack.sh
> > +++ b/t/t5500-fetch-pack.sh
> > @@ -30,7 +30,7 @@ add () {
> >  	test_tick &&
> >  	commit=$(echo "$text" | git commit-tree $tree $parents) &&
> >  	eval "$name=$commit; export $name" &&
> > -	echo $commit > .git/refs/heads/$branch &&
> > +	git update-ref refs/heads/$branch $commit &&
> 
> I think we have to be careful here to quote both "refs/heads/$branch" and
> "$commit" here, as a bug that introduces spaces into $commit or $branch
> would have been caught earlier, but not now, unless we quote.
> 
> This goes for all introduced `update-ref` calls.
> 
> Maybe even for some `git rev-parse --verify` calls.
> 
> > diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> > index 8f5c811dd7..c3b89ae783 100755
> > --- a/t/t9903-bash-prompt.sh
> > +++ b/t/t9903-bash-prompt.sh
> > @@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
> >  test_expect_success 'prompt - deep inside .git directory' '
> >  	printf " (GIT_DIR!)" >expected &&
> >  	(
> > -		cd .git/refs/heads &&
> > +		cd .git/objects &&
> >  		__git_ps1 >"$actual"
> >  	) &&
> >  	test_cmp expected "$actual"
> > -- 
> 
> This one looks wrong.
> 
> Upon cursory review, one might be tempted to assume that the file is now
> written into .git/objects/ instead of .git/refs/heads/. And the patch
> context provided in the email is not enough to see (gawd, I hate
> mail-based patch review, it really takes all my Git tools away from me).
> The trick is that `actual` points at an absolute path:
> 
> 	#!/bin/sh
> 	#
> 	# Copyright (c) 2012 SZEDER Gábor
> 	#
> 
> 	test_description='test git-specific bash prompt functions'
> 
> 	. ./lib-bash.sh
> 
> 	. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
> 
> 	actual="$TRASH_DIRECTORY/actual"
> 	[...]
> 
> So the remaining question (which probably wants to be added to the commit
> message together with a hint that `actual` points at an absolute path) is:
> Why not `cd .git` instead?
> 
> Ciao,
> Dscho

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21  5:51 [PATCH] t: make many tests depend less on the refs being files Christian Couder
  2018-05-21  9:41 ` Johannes Schindelin
@ 2018-05-21 19:34 ` Stefan Beller
  2018-05-23  5:33   ` Christian Couder
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Beller @ 2018-05-21 19:34 UTC (permalink / raw)
  To: Christian Couder
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Jonathan Nieder, Jonathan Tan, Duy Nguyen, Derrick Stolee,
	Carlos Martín Nieto, Michael Haggerty, David Turner,
	Christian Couder, David Turner

On Sun, May 20, 2018 at 10:51 PM, Christian Couder
<christian.couder@gmail.com> wrote:
> From: David Turner <dturner@twopensource.com>
>
> So that they work under alternate ref storage backends.

Sometimes I have a disconnect between the subject and the commit
message, (e.g. in an email reader the subject is not displayed accurately on
top of the message).

So I would prefer if the first part of the body message is an actual
sentence, and
not a continuum from the subject.

Maybe elaborate a bit more:

  The current tests are very focused on the file system representation of
  the loose and packed refs code.  As there are plans to implement other
  ref storage systems, migrate most tests to a form that test the intent of the
  refs storage system instead of it internals. The internals of the loose and
  packed refs are tested in <TODO>, whereas the tests in this patch focus
  on testing other aspects.

>
> This will be really needed when such alternate ref storage backends are
> developed. But this could already help by making clear to readers that
> some tests do not depend on which ref backend is used.

Ah, this is what I picked up already in the suggested edit above. :/

> This patch just takes care of many low hanging fruits. It does not try
> to completely solves the issue.
>
> Signed-off-by: David Turner <dturner@twopensource.com>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>



> ---
>
> Thanks for all the great feedback regarding implementing reftable [1].
>
> Looking at David Turner's tests in [2], it seems that they could indeed
> be already valuable, so let's start by extracting most of the simple
> improvements they make.

Thanks for tackling refstables!

Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21 11:49   ` SZEDER Gábor
@ 2018-05-23  5:27     ` Christian Couder
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Couder @ 2018-05-23  5:27 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Johannes Schindelin, git, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Stefan Beller,
	Jonathan Nieder, Jonathan Tan, Duy Nguyen, Derrick Stolee,
	Carlos Martín Nieto, Michael Haggerty, David Turner,
	Christian Couder, David Turner

On Mon, May 21, 2018 at 1:49 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:
>> > diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
>> > index 8f5c811dd7..c3b89ae783 100755
>> > --- a/t/t9903-bash-prompt.sh
>> > +++ b/t/t9903-bash-prompt.sh
>> > @@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
>> >  test_expect_success 'prompt - deep inside .git directory' '
>> >     printf " (GIT_DIR!)" >expected &&
>> >     (
>> > -           cd .git/refs/heads &&
>> > +           cd .git/objects &&
>> >             __git_ps1 >"$actual"
>> >     ) &&
>> >     test_cmp expected "$actual"
>>
>> This one looks wrong.
>
> It's right, though.
>
>> Why not `cd .git` instead?
>
> That case is covered in the previous test.
>
> Once upon a time it mattered how deep we were in the .git directory
> when running __git_ps1(), because it executed different branches of a
> long-ish if-elif chain.  For the prompt it doesn't matter anymore,
> because those ifs were eliminated, but for the completion script it
> still does, which brings us to:

Thanks for the explanations!

> Christian!  There is a similar test, '__git_find_repo_path - parent is
> a .git directory' in 't9902-completion.sh', which, too, performs a 'cd
> .git/refs/heads'.

Ok, I will take care of both of these tests in another patch.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] t: make many tests depend less on the refs being files
  2018-05-21 19:34 ` Stefan Beller
@ 2018-05-23  5:33   ` Christian Couder
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Couder @ 2018-05-23  5:33 UTC (permalink / raw)
  To: Stefan Beller
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Jonathan Nieder, Jonathan Tan, Duy Nguyen, Derrick Stolee,
	Carlos Martín Nieto, Michael Haggerty, David Turner,
	Christian Couder, David Turner

On Mon, May 21, 2018 at 9:34 PM, Stefan Beller <sbeller@google.com> wrote:
> On Sun, May 20, 2018 at 10:51 PM, Christian Couder
> <christian.couder@gmail.com> wrote:
>> From: David Turner <dturner@twopensource.com>
>>
>> So that they work under alternate ref storage backends.
>
> Sometimes I have a disconnect between the subject and the commit
> message, (e.g. in an email reader the subject is not displayed accurately on
> top of the message).
>
> So I would prefer if the first part of the body message is an actual
> sentence, and
> not a continuum from the subject.
>
> Maybe elaborate a bit more:
>
>   The current tests are very focused on the file system representation of
>   the loose and packed refs code.  As there are plans to implement other
>   ref storage systems, migrate most tests to a form that test the intent of the
>   refs storage system instead of it internals. The internals of the loose and
>   packed refs are tested in <TODO>, whereas the tests in this patch focus
>   on testing other aspects.

Thanks for this suggestion!

>> This will be really needed when such alternate ref storage backends are
>> developed. But this could already help by making clear to readers that
>> some tests do not depend on which ref backend is used.
>
> Ah, this is what I picked up already in the suggested edit above. :/

I actually mixed parts of your suggested message with parts of the
existing message in the V2 I just sent:

https://public-inbox.org/git/20180523052517.4443-1-chriscool@tuxfamily.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-23  5:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21  5:51 [PATCH] t: make many tests depend less on the refs being files Christian Couder
2018-05-21  9:41 ` Johannes Schindelin
2018-05-21 11:49   ` SZEDER Gábor
2018-05-23  5:27     ` Christian Couder
2018-05-21 12:30   ` Christian Couder
2018-05-21 12:37   ` Johannes Schindelin
2018-05-21 19:34 ` Stefan Beller
2018-05-23  5:33   ` Christian Couder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).