git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] *** Avoid using Pipes ***
@ 2023-10-03 17:48 ach.lumap
  2023-10-03 17:48 ` [PATCH 1/1] t2400: avoid using pipes ach.lumap
  2023-11-30 16:54 ` [PATCH v2 0/1] *** Avoid using Pipes *** Achu Luma
  0 siblings, 2 replies; 10+ messages in thread
From: ach.lumap @ 2023-10-03 17:48 UTC (permalink / raw)
  To: git; +Cc: christian.couder, achluma

From: achluma <achluma@gmail.com>

*** BLURB HERE ***

achluma (1):
  t2400: avoid using pipes

 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


base-commit: d0e8084c65cbf949038ae4cc344ac2c2efd77415
-- 
2.41.0.windows.1


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

* [PATCH 1/1] t2400: avoid using pipes
  2023-10-03 17:48 [PATCH 0/1] *** Avoid using Pipes *** ach.lumap
@ 2023-10-03 17:48 ` ach.lumap
  2023-10-03 18:01   ` Eric Sunshine
  2023-11-30 16:54 ` [PATCH v2 0/1] *** Avoid using Pipes *** Achu Luma
  1 sibling, 1 reply; 10+ messages in thread
From: ach.lumap @ 2023-10-03 17:48 UTC (permalink / raw)
  To: git; +Cc: christian.couder, achluma

From: achluma <ach.lumap@gmail.com>

The exit code of the preceding command in a pipe is disregarded,
so it's advisable to refrain from relying on it. Instead, by
saving the output of a Git command to a file, we gain the
ability to examine the exit codes of both commands separately.

Signed-off-by: achluma <ach.lumap@gmail.com>
---
 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index df4aff7825..7ead05bb98 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
 		cd under-rebase &&
 		set_fake_editor &&
 		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-		git worktree list | grep "under-rebase.*detached HEAD"
+		git worktree list >actual && 
+		grep "under-rebase.*detached HEAD" actual
 	)
 '
 
@@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
 		git bisect start &&
 		git bisect bad &&
 		git bisect good HEAD~2 &&
-		git worktree list | grep "under-bisect.*detached HEAD" &&
+		git worktree list >actual && 
+		grep "under-bisect.*detached HEAD" actual &&
 		test_must_fail git worktree add new-bisect under-bisect &&
 		! test -d new-bisect
 	)
-- 
2.41.0.windows.1


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

* Re: [PATCH 1/1] t2400: avoid using pipes
  2023-10-03 17:48 ` [PATCH 1/1] t2400: avoid using pipes ach.lumap
@ 2023-10-03 18:01   ` Eric Sunshine
  2023-10-03 18:42     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sunshine @ 2023-10-03 18:01 UTC (permalink / raw)
  To: ach.lumap; +Cc: git, christian.couder

On Tue, Oct 3, 2023 at 1:49 PM <ach.lumap@gmail.com> wrote:
> t2400: avoid using pipes

Pipes themselves are not necessarily problematic, and there are many
places in the test suite where they are legitimately used. Rather...

> The exit code of the preceding command in a pipe is disregarded,
> so it's advisable to refrain from relying on it. Instead, by
> saving the output of a Git command to a file, we gain the
> ability to examine the exit codes of both commands separately.

... as you correctly explain here, we don't want to lose the exit code
from the Git command. Thus, if you want to convey more information to
readers of `git log --oneline` (or other such commands), a better
subject for the patch might be:

    t2400: avoid losing Git exit code

That minor comment aside (which is probably not worth a reroll), the
commit message properly explains why this change is desirable and the
patch itself looks good.

> Signed-off-by: achluma <ach.lumap@gmail.com>
> ---
> diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
> @@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
>                 cd under-rebase &&
>                 set_fake_editor &&
>                 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
> -               git worktree list | grep "under-rebase.*detached HEAD"
> +               git worktree list >actual &&

Thanks for following the style guideline and omitting whitespace
between the redirection operator and the destination file.

> +               grep "under-rebase.*detached HEAD" actual
>         )
>  '
>
> @@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
>                 git bisect start &&
>                 git bisect bad &&
>                 git bisect good HEAD~2 &&
> -               git worktree list | grep "under-bisect.*detached HEAD" &&
> +               git worktree list >actual &&
> +               grep "under-bisect.*detached HEAD" actual &&
>                 test_must_fail git worktree add new-bisect under-bisect &&
>                 ! test -d new-bisect
>         )

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

* Re: [PATCH 1/1] t2400: avoid using pipes
  2023-10-03 18:01   ` Eric Sunshine
@ 2023-10-03 18:42     ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2023-10-03 18:42 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: ach.lumap, git, christian.couder

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Tue, Oct 3, 2023 at 1:49 PM <ach.lumap@gmail.com> wrote:
>> t2400: avoid using pipes
>
> Pipes themselves are not necessarily problematic, and there are many
> places in the test suite where they are legitimately used. Rather...
> ...
> readers of `git log --oneline` (or other such commands), a better
> subject for the patch might be:
>
>     t2400: avoid losing Git exit code
>
> That minor comment aside (which is probably not worth a reroll), the
> commit message properly explains why this change is desirable and the
> patch itself looks good.

Thanks for writing and reviewing.  Will queue.

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

* [PATCH v2 0/1] *** Avoid using Pipes ***
  2023-10-03 17:48 [PATCH 0/1] *** Avoid using Pipes *** ach.lumap
  2023-10-03 17:48 ` [PATCH 1/1] t2400: avoid using pipes ach.lumap
@ 2023-11-30 16:54 ` Achu Luma
  2023-11-30 16:54   ` [PATCH v2 1/1] t2400: avoid using pipes Achu Luma
  1 sibling, 1 reply; 10+ messages in thread
From: Achu Luma @ 2023-11-30 16:54 UTC (permalink / raw)
  To: git; +Cc: Achu Luma

*** BLURB HERE ***

Achu Luma (1):
  t2400: avoid using pipes

 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


base-commit: d0e8084c65cbf949038ae4cc344ac2c2efd77415
-- 
2.41.0.windows.1


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

* [PATCH v2 1/1] t2400: avoid using pipes
  2023-11-30 16:54 ` [PATCH v2 0/1] *** Avoid using Pipes *** Achu Luma
@ 2023-11-30 16:54   ` Achu Luma
  2023-11-30 18:16     ` Christian Couder
  0 siblings, 1 reply; 10+ messages in thread
From: Achu Luma @ 2023-11-30 16:54 UTC (permalink / raw)
  To: git; +Cc: Achu Luma

The exit code of the preceding command in a pipe is disregarded,
so it's advisable to refrain from relying on it. Instead, by
saving the output of a Git command to a file, we gain the
ability to examine the exit codes of both commands separately.

Signed-off-by: achluma <ach.lumap@gmail.com>
---
 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index df4aff7825..7ead05bb98 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
 		cd under-rebase &&
 		set_fake_editor &&
 		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-		git worktree list | grep "under-rebase.*detached HEAD"
+		git worktree list >actual && 
+		grep "under-rebase.*detached HEAD" actual
 	)
 '
 
@@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
 		git bisect start &&
 		git bisect bad &&
 		git bisect good HEAD~2 &&
-		git worktree list | grep "under-bisect.*detached HEAD" &&
+		git worktree list >actual && 
+		grep "under-bisect.*detached HEAD" actual &&
 		test_must_fail git worktree add new-bisect under-bisect &&
 		! test -d new-bisect
 	)
-- 
2.41.0.windows.1


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

* Re: [PATCH v2 1/1] t2400: avoid using pipes
  2023-11-30 16:54   ` [PATCH v2 1/1] t2400: avoid using pipes Achu Luma
@ 2023-11-30 18:16     ` Christian Couder
  2023-12-04 15:37       ` [Outreachy][PATCH v3] " Achu Luma
  0 siblings, 1 reply; 10+ messages in thread
From: Christian Couder @ 2023-11-30 18:16 UTC (permalink / raw)
  To: Achu Luma; +Cc: git

Hi Luma,

On Thu, Nov 30, 2023 at 6:37 PM Achu Luma <ach.lumap@gmail.com> wrote:
>
> The exit code of the preceding command in a pipe is disregarded,
> so it's advisable to refrain from relying on it. Instead, by
> saving the output of a Git command to a file, we gain the
> ability to examine the exit codes of both commands separately.
>
> Signed-off-by: achluma <ach.lumap@gmail.com>

I think the issue with merging your patch (in
https://lore.kernel.org/git/xmqqedibzgi1.fsf@gitster.g/) was that this
"Signed-off-by: ..." line didn't show your full real name and didn't
match your name in your email address.

Assuming that "Achu Luma" is your full real name, you should replace
"achluma" with "Achu Luma" in the "Signed-off-by: ..." line.

Also it's better not to send a cover letter patch like
https://lore.kernel.org/git/20231130165429.2595-1-ach.lumap@gmail.com/
with no content for small patches like this.

When you resend, please also make sure to use [Outreachy] in the patch
subject and to increment the version number of the patch, using for
example "[PATCH v3]".

It would be nice too if after the line starting with --- below, you
could describe in a few lines the changes in the new version of the
patch compared to the previous version.

> ---

Here (after the line starting with --- above) is the place where you
can tell what changed in the patch compared to the previous version.

Note that when there is a cover letter patch, it's better to talk
about changes in the new version in the cover letter, but I dont think
it's worth sending a cover letter patch.

Thanks,
Christian.

>  t/t2400-worktree-add.sh | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
> index df4aff7825..7ead05bb98 100755
> --- a/t/t2400-worktree-add.sh
> +++ b/t/t2400-worktree-add.sh
> @@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
>                 cd under-rebase &&
>                 set_fake_editor &&
>                 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
> -               git worktree list | grep "under-rebase.*detached HEAD"
> +               git worktree list >actual &&
> +               grep "under-rebase.*detached HEAD" actual
>         )
>  '
>
> @@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
>                 git bisect start &&
>                 git bisect bad &&
>                 git bisect good HEAD~2 &&
> -               git worktree list | grep "under-bisect.*detached HEAD" &&
> +               git worktree list >actual &&
> +               grep "under-bisect.*detached HEAD" actual &&
>                 test_must_fail git worktree add new-bisect under-bisect &&
>                 ! test -d new-bisect
>         )
> --
> 2.41.0.windows.1
>
>

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

* [Outreachy][PATCH v3] t2400: avoid using pipes
  2023-11-30 18:16     ` Christian Couder
@ 2023-12-04 15:37       ` Achu Luma
  2023-12-08 21:00         ` Junio C Hamano
  2024-01-20  2:15         ` [Outreachy][PATCH v4] t2400: avoid losing exit status to pipes Achu Luma
  0 siblings, 2 replies; 10+ messages in thread
From: Achu Luma @ 2023-12-04 15:37 UTC (permalink / raw)
  To: christian.couder; +Cc: ach.lumap, git

The exit code of the preceding command in a pipe is disregarded,
so it's advisable to refrain from relying on it. Instead, by
saving the output of a Git command to a file, we gain the
ability to examine the exit codes of both commands separately.

Signed-off-by: Achu Luma <ach.lumap@gmail.com>
---
 Since v2 I don't send a cover  letter anymore, and I changed 
 my "Signed-of-by: ..." line so that it
 contains my full real name and I added "Outreachy" to the subject.

 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index df4aff7825..7ead05bb98 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
 		cd under-rebase &&
 		set_fake_editor &&
 		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-		git worktree list | grep "under-rebase.*detached HEAD"
+		git worktree list >actual && 
+		grep "under-rebase.*detached HEAD" actual
 	)
 '
 
@@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
 		git bisect start &&
 		git bisect bad &&
 		git bisect good HEAD~2 &&
-		git worktree list | grep "under-bisect.*detached HEAD" &&
+		git worktree list >actual && 
+		grep "under-bisect.*detached HEAD" actual &&
 		test_must_fail git worktree add new-bisect under-bisect &&
 		! test -d new-bisect
 	)
-- 
2.41.0.windows.1


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

* Re: [Outreachy][PATCH v3] t2400: avoid using pipes
  2023-12-04 15:37       ` [Outreachy][PATCH v3] " Achu Luma
@ 2023-12-08 21:00         ` Junio C Hamano
  2024-01-20  2:15         ` [Outreachy][PATCH v4] t2400: avoid losing exit status to pipes Achu Luma
  1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2023-12-08 21:00 UTC (permalink / raw)
  To: Achu Luma; +Cc: christian.couder, git

Achu Luma <ach.lumap@gmail.com> writes:

> Subject: Re: [Outreachy][PATCH v3] t2400: avoid using pipes

"avoid using pipes" is a means to an end.  And it is more important
to tell readers what that "end" is.  With this patch, what are we
trying to achieve?  Cater to platforms that lack pipes?  Help
platforms that cannot run two processes at the same time, so let one
run and store the result in a file, and then let the other one run,
to reduce the CPU load?

If we run a "git" command, especially a command we are testing, on
the upstream side of a pipe, we lose information.  We cannot tell
what exit status the command exited with.  That is what we care
about.

So, it is better to say that in the title, e.g.,

    Subject: [PATCH] t2400: avoid losing exit status to pipes

> The exit code of the preceding command in a pipe is disregarded,
> so it's advisable to refrain from relying on it.

It is unclear what "it" refers to here.  We cannot rely on the exit
code of the command on the upstream side of a pipe, obviously.

> Instead, by
> saving the output of a Git command to a file, we gain the
> ability to examine the exit codes of both commands separately.

Surely.  I personally think that the title that says what the
purpose of the patch is clearly should be sufficient without any
further description in the body, though.
>
> Signed-off-by: Achu Luma <ach.lumap@gmail.com>
> ---
>  Since v2 I don't send a cover  letter anymore, and I changed 
>  my "Signed-of-by: ..." line so that it
>  contains my full real name and I added "Outreachy" to the subject.

Nicely done.

>
>  t/t2400-worktree-add.sh | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
> index df4aff7825..7ead05bb98 100755
> --- a/t/t2400-worktree-add.sh
> +++ b/t/t2400-worktree-add.sh
> @@ -468,7 +468,8 @@ test_expect_success 'put a worktree under rebase' '
>  		cd under-rebase &&
>  		set_fake_editor &&
>  		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
> -		git worktree list | grep "under-rebase.*detached HEAD"
> +		git worktree list >actual && 
> +		grep "under-rebase.*detached HEAD" actual
>  	)
>  '
>  
> @@ -509,7 +510,8 @@ test_expect_success 'checkout a branch under bisect' '
>  		git bisect start &&
>  		git bisect bad &&
>  		git bisect good HEAD~2 &&
> -		git worktree list | grep "under-bisect.*detached HEAD" &&
> +		git worktree list >actual && 
> +		grep "under-bisect.*detached HEAD" actual &&
>  		test_must_fail git worktree add new-bisect under-bisect &&
>  		! test -d new-bisect
>  	)

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

* [Outreachy][PATCH v4] t2400: avoid losing exit status to pipes
  2023-12-04 15:37       ` [Outreachy][PATCH v3] " Achu Luma
  2023-12-08 21:00         ` Junio C Hamano
@ 2024-01-20  2:15         ` Achu Luma
  1 sibling, 0 replies; 10+ messages in thread
From: Achu Luma @ 2024-01-20  2:15 UTC (permalink / raw)
  To: git; +Cc: christian.couder, gitster, Achu Luma

The exit code of the preceding command in a pipe is disregarded. So
if that preceding command is a Git command that fails, the test would
not fail. Instead, by saving the output of that Git command to a file,
and removing the pipe, we make sure the test will fail if that Git
command fails.

Signed-off-by: Achu Luma <ach.lumap@gmail.com>
---
 The difference between v3 and v4 is:
 - Changed subject to better reflect what the patch is doing.
 - Updated the commit message.

 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 3742971105..b597004adb 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -490,7 +490,8 @@ test_expect_success 'put a worktree under rebase' '
 		cd under-rebase &&
 		set_fake_editor &&
 		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-		git worktree list | grep "under-rebase.*detached HEAD"
+		git worktree list >actual &&
+		grep "under-rebase.*detached HEAD" actual
 	)
 '

@@ -531,7 +532,8 @@ test_expect_success 'checkout a branch under bisect' '
 		git bisect start &&
 		git bisect bad &&
 		git bisect good HEAD~2 &&
-		git worktree list | grep "under-bisect.*detached HEAD" &&
+		git worktree list >actual &&
+		grep "under-bisect.*detached HEAD" actual &&
 		test_must_fail git worktree add new-bisect under-bisect &&
 		! test -d new-bisect
 	)
--
2.43.0.windows.1


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

end of thread, other threads:[~2024-01-20  2:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 17:48 [PATCH 0/1] *** Avoid using Pipes *** ach.lumap
2023-10-03 17:48 ` [PATCH 1/1] t2400: avoid using pipes ach.lumap
2023-10-03 18:01   ` Eric Sunshine
2023-10-03 18:42     ` Junio C Hamano
2023-11-30 16:54 ` [PATCH v2 0/1] *** Avoid using Pipes *** Achu Luma
2023-11-30 16:54   ` [PATCH v2 1/1] t2400: avoid using pipes Achu Luma
2023-11-30 18:16     ` Christian Couder
2023-12-04 15:37       ` [Outreachy][PATCH v3] " Achu Luma
2023-12-08 21:00         ` Junio C Hamano
2024-01-20  2:15         ` [Outreachy][PATCH v4] t2400: avoid losing exit status to pipes Achu Luma

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 NNTP newsgroup(s).