Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commands
@ 2020-10-17 16:02 Amanda  Shafack  via GitGitGadget
  2020-10-17 16:02 ` [PATCH 1/2] t9832,t2200: avoid using pipes in git commands Amanda Shafack via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Amanda  Shafack  via GitGitGadget @ 2020-10-17 16:02 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer, Jonathan Nieder, Amanda Shafack

When the upstream of a pipe throws an error, the downstream still executes
normally. This happens because the exit code of the upstream in a pipe is
ignored. This behavior can make debugging very hard in case a test fails.
Also, pipes are prone to deadlocks. If the upstream gets full, the commands
downstream will never start.

Write out the output of the git command to a file, so as to test the exit
codes of both commands.

Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that the
exit code of upstream in the pipe is ignored, thus using pipes should be
avoided.

Signed-off-by: Amanda Shafack shafack.likhene@gmail.com
[shafack.likhene@gmail.com]

Amanda  Shafack (1):
  t2200: modify code syntax

Amanda Shafack (1):
  t9832,t2200: avoid using pipes in git commands

 t/t2200-add-update.sh | 3 ++-
 t/t9832-unshelve.sh   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)


base-commit: a5fa49ff0a8f3252c6bff49f92b85e7683868f8a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-885%2Flkmandy%2Favoid-pipes-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-885/lkmandy/avoid-pipes-v1
Pull-Request: https://github.com/git/git/pull/885
-- 
gitgitgadget

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

* [PATCH 1/2] t9832,t2200: avoid using pipes in git commands
  2020-10-17 16:02 [PATCH 0/2] [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commands Amanda  Shafack  via GitGitGadget
@ 2020-10-17 16:02 ` Amanda Shafack via GitGitGadget
  2020-10-18  6:11   ` Eric Sunshine
  2020-10-17 16:02 ` [PATCH 2/2] t2200: modify code syntax Amanda  Shafack via GitGitGadget
  2020-10-18 14:42 ` [PATCH v2] t9832,t2200: avoid using pipes in git commands Amanda  Shafack  via GitGitGadget
  2 siblings, 1 reply; 14+ messages in thread
From: Amanda Shafack via GitGitGadget @ 2020-10-17 16:02 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer, Jonathan Nieder, Amanda Shafack, Amanda Shafack

From: Amanda Shafack <shafack.likhene@gmail.com>

When the upstream of a pipe throws an error, the downstream still
executes normally. This happens because the exit code of the upstream
in a pipe is ignored. This behavior can make debugging very hard
incase a test fails. Also, pipes are prone to deadlocks. If the
upstream gets full, the commands downstream will never start.

Write out the output of the git command to a file, so as to test the
exit codes of both commands.

Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that
the exit code of upstream in the pipe is ignored, thus using pipes
should be avoided.

Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
---
 t/t2200-add-update.sh | 5 ++++-
 t/t9832-unshelve.sh   | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index f764b7e3f5..2d850bb372 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -179,7 +179,10 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 test_expect_success '"add -u non-existent" should fail' '
 	test_must_fail git add -u non-existent &&
-	! (git ls-files | grep "non-existent")
+	! (
+		git ls-files >actual &&
+		grep "non-existent" actual
+	)
 '
 
 test_done
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index 7194fb2855..6b3cb0414a 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -68,7 +68,8 @@ EOF
 		cd "$git" &&
 		change=$(last_shelved_change) &&
 		git p4 unshelve $change &&
-		git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
+		git show refs/remotes/p4-unshelved/$change >actual &&
+		grep -q "Further description" actual &&
 		git cherry-pick refs/remotes/p4-unshelved/$change &&
 		test_path_is_file file2 &&
 		test_cmp file1 "$cli"/file1 &&
-- 
gitgitgadget


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

* [PATCH 2/2] t2200: modify code syntax
  2020-10-17 16:02 [PATCH 0/2] [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commands Amanda  Shafack  via GitGitGadget
  2020-10-17 16:02 ` [PATCH 1/2] t9832,t2200: avoid using pipes in git commands Amanda Shafack via GitGitGadget
@ 2020-10-17 16:02 ` Amanda  Shafack via GitGitGadget
  2020-10-18  5:55   ` Eric Sunshine
  2020-10-18 14:42 ` [PATCH v2] t9832,t2200: avoid using pipes in git commands Amanda  Shafack  via GitGitGadget
  2 siblings, 1 reply; 14+ messages in thread
From: Amanda  Shafack via GitGitGadget @ 2020-10-17 16:02 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer, Jonathan Nieder, Amanda Shafack, Amanda Shafack

From: Amanda  Shafack <shafack.likhene@gmail.com>

Using the logical not operator on both the git and grep command is
redundant, since the main check is done at the level of the grep
command.

Apply the logical not operator only to the grep command.

Co-authored-by: Johannes Schindelin <dscho@github.com>
Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
---
 t/t2200-add-update.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 2d850bb372..7cb7a70382 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -179,10 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 test_expect_success '"add -u non-existent" should fail' '
 	test_must_fail git add -u non-existent &&
-	! (
-		git ls-files >actual &&
-		grep "non-existent" actual
-	)
+	git ls-files >actual &&
+	! grep "non-existent" actual
 '
 
 test_done
-- 
gitgitgadget

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

* Re: [PATCH 2/2] t2200: modify code syntax
  2020-10-17 16:02 ` [PATCH 2/2] t2200: modify code syntax Amanda  Shafack via GitGitGadget
@ 2020-10-18  5:55   ` Eric Sunshine
  2020-10-18 13:59     ` Amanda Shafack
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Sunshine @ 2020-10-18  5:55 UTC (permalink / raw)
  To: Amanda Shafack via GitGitGadget
  Cc: Git List, Emily Shaffer, Jonathan Nieder, Amanda Shafack

On Sat, Oct 17, 2020 at 12:02 PM Amanda Shafack via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> Using the logical not operator on both the git and grep command is
> redundant, since the main check is done at the level of the grep
> command.
>
> Apply the logical not operator only to the grep command.
> ---
> diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
> @@ -179,10 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
> -       ! (
> -               git ls-files >actual &&
> -               grep "non-existent" actual
> -       )
> +       git ls-files >actual &&
> +       ! grep "non-existent" actual

The commit message talks only about redundancy of applying the logical
NOT operator to the combined subshell content, but what it misses is
that transformation of:

    ! (git ls-files | grep "non-existent")

in patch [1/2] into:

    ! (
        git ls-files >actual &&
        grep "non-existent" actual
    )

is actively wrong. In particular, if `git ls-files` itself fails, then
the `grep` will never get run, and the subshell will exit with a
failure, however, the NOT then turns that failure into a success,
which is quite undesirable. The test should fail if either `git
ls-files` fails or if the `grep` expectation is not met; it should not
succeed when `git ls-files` fails.

So, the correct thing to do is to merge [1/2] and [2/2] into a single
patch which directly transforms:

    ! (git ls-files | grep "non-existent")

into:

    git ls-files >actual &&
    ! grep "non-existent" actual

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

* Re: [PATCH 1/2] t9832,t2200: avoid using pipes in git commands
  2020-10-17 16:02 ` [PATCH 1/2] t9832,t2200: avoid using pipes in git commands Amanda Shafack via GitGitGadget
@ 2020-10-18  6:11   ` Eric Sunshine
  2020-10-18 13:57     ` Amanda Shafack
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Sunshine @ 2020-10-18  6:11 UTC (permalink / raw)
  To: Amanda Shafack via GitGitGadget
  Cc: Git List, Emily Shaffer, Jonathan Nieder, Amanda Shafack

On Sat, Oct 17, 2020 at 12:02 PM Amanda Shafack via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> When the upstream of a pipe throws an error, the downstream still
> executes normally. This happens because the exit code of the upstream
> in a pipe is ignored. This behavior can make debugging very hard
> incase a test fails.

To be more precise, we're not worried about difficulty of debugging
when a Git command is upstream in a pipe. What we are more concerned
with is that an unexpected failure of the Git command will go
unnoticed (unless it also happens to produce wrong output which is
later caught somewhere downstream). By avoiding placing Git upstream
in a pipe, we can actively catch a failure of the Git command. The
commit message should focus on that reason instead.

> Also, pipes are prone to deadlocks. If the
> upstream gets full, the commands downstream will never start.

I don't think this is ever an issue in Git tests, so talking about it
here probably only muddies the waters, thus makes the commit message
less precise and more hand-wavy. Dropping this sentence is
recommended.

> Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that
> the exit code of upstream in the pipe is ignored, thus using pipes
> should be avoided.

There are a lot of commits in the project history which perform this
sort of transformation, so it's not clear to the reader why this
particular commit is called out as being important. If it's not, then
I'd recommend dropping this sentence, as well.

> diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
>  test_expect_success '"add -u non-existent" should fail' '
>         test_must_fail git add -u non-existent &&
> -       ! (git ls-files | grep "non-existent")
> +       ! (
> +               git ls-files >actual &&
> +               grep "non-existent" actual
> +       )
>  '

This transformation appears to be incorrect. See my review of patch
[2/2] for details.

> diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
> @@ -68,7 +68,8 @@ EOF
> -               git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
> +               git show refs/remotes/p4-unshelved/$change >actual &&
> +               grep -q "Further description" actual &&

This transformation looks fine.

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

* Re: [PATCH 1/2] t9832,t2200: avoid using pipes in git commands
  2020-10-18  6:11   ` Eric Sunshine
@ 2020-10-18 13:57     ` Amanda Shafack
  0 siblings, 0 replies; 14+ messages in thread
From: Amanda Shafack @ 2020-10-18 13:57 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Amanda Shafack via GitGitGadget, Git List, Emily Shaffer,
	Jonathan Nieder

Thanks for your feedback, I now have a better understanding. I have
made the changes you requested.


On Sun, Oct 18, 2020 at 7:11 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Sat, Oct 17, 2020 at 12:02 PM Amanda Shafack via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > When the upstream of a pipe throws an error, the downstream still
> > executes normally. This happens because the exit code of the upstream
> > in a pipe is ignored. This behavior can make debugging very hard
> > incase a test fails.
>
> To be more precise, we're not worried about difficulty of debugging
> when a Git command is upstream in a pipe. What we are more concerned
> with is that an unexpected failure of the Git command will go
> unnoticed (unless it also happens to produce wrong output which is
> later caught somewhere downstream). By avoiding placing Git upstream
> in a pipe, we can actively catch a failure of the Git command. The
> commit message should focus on that reason instead.
>
> > Also, pipes are prone to deadlocks. If the
> > upstream gets full, the commands downstream will never start.
>
> I don't think this is ever an issue in Git tests, so talking about it
> here probably only muddies the waters, thus makes the commit message
> less precise and more hand-wavy. Dropping this sentence is
> recommended.
>
> > Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that
> > the exit code of upstream in the pipe is ignored, thus using pipes
> > should be avoided.
>
> There are a lot of commits in the project history which perform this
> sort of transformation, so it's not clear to the reader why this
> particular commit is called out as being important. If it's not, then
> I'd recommend dropping this sentence, as well.
>
> > diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
> >  test_expect_success '"add -u non-existent" should fail' '
> >         test_must_fail git add -u non-existent &&
> > -       ! (git ls-files | grep "non-existent")
> > +       ! (
> > +               git ls-files >actual &&
> > +               grep "non-existent" actual
> > +       )
> >  '
>
> This transformation appears to be incorrect. See my review of patch
> [2/2] for details.
>
> > diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
> > @@ -68,7 +68,8 @@ EOF
> > -               git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
> > +               git show refs/remotes/p4-unshelved/$change >actual &&
> > +               grep -q "Further description" actual &&
>
> This transformation looks fine.



-- 

Cheers!

Amanda  Shafack

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

* Re: [PATCH 2/2] t2200: modify code syntax
  2020-10-18  5:55   ` Eric Sunshine
@ 2020-10-18 13:59     ` Amanda Shafack
  0 siblings, 0 replies; 14+ messages in thread
From: Amanda Shafack @ 2020-10-18 13:59 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Amanda Shafack via GitGitGadget, Git List, Emily Shaffer,
	Jonathan Nieder

I agree with you. I have made these changes as well.
Thanks


On Sun, Oct 18, 2020 at 6:56 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Sat, Oct 17, 2020 at 12:02 PM Amanda Shafack via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > Using the logical not operator on both the git and grep command is
> > redundant, since the main check is done at the level of the grep
> > command.
> >
> > Apply the logical not operator only to the grep command.
> > ---
> > diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
> > @@ -179,10 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
> > -       ! (
> > -               git ls-files >actual &&
> > -               grep "non-existent" actual
> > -       )
> > +       git ls-files >actual &&
> > +       ! grep "non-existent" actual
>
> The commit message talks only about redundancy of applying the logical
> NOT operator to the combined subshell content, but what it misses is
> that transformation of:
>
>     ! (git ls-files | grep "non-existent")
>
> in patch [1/2] into:
>
>     ! (
>         git ls-files >actual &&
>         grep "non-existent" actual
>     )
>
> is actively wrong. In particular, if `git ls-files` itself fails, then
> the `grep` will never get run, and the subshell will exit with a
> failure, however, the NOT then turns that failure into a success,
> which is quite undesirable. The test should fail if either `git
> ls-files` fails or if the `grep` expectation is not met; it should not
> succeed when `git ls-files` fails.
>
> So, the correct thing to do is to merge [1/2] and [2/2] into a single
> patch which directly transforms:
>
>     ! (git ls-files | grep "non-existent")
>
> into:
>
>     git ls-files >actual &&
>     ! grep "non-existent" actual



-- 

Cheers!

Amanda  Shafack

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

* [PATCH v2] t9832,t2200: avoid using pipes in git commands
  2020-10-17 16:02 [PATCH 0/2] [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commands Amanda  Shafack  via GitGitGadget
  2020-10-17 16:02 ` [PATCH 1/2] t9832,t2200: avoid using pipes in git commands Amanda Shafack via GitGitGadget
  2020-10-17 16:02 ` [PATCH 2/2] t2200: modify code syntax Amanda  Shafack via GitGitGadget
@ 2020-10-18 14:42 ` Amanda  Shafack  via GitGitGadget
  2020-10-18 19:25   ` Eric Sunshine
  2020-10-18 20:48   ` [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe Amanda  Shafack  via GitGitGadget
  2 siblings, 2 replies; 14+ messages in thread
From: Amanda  Shafack  via GitGitGadget @ 2020-10-18 14:42 UTC (permalink / raw)
  To: git
  Cc: Emily Shaffer, Jonathan Nieder, Eric Sunshine, Amanda Shafack,
	Amanda Shafack, Amanda Shafack

From: Amanda Shafack <shafack.likhene@gmail.com>

When a git command is upstream in a pipe, an unexpected failure of
the git command will go unnoticed.

Write out the output of the git command to a file, so as to actively
catch a failure of the git command.

Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
---
    [Outreachy][Patch v2] t9832,t2200: avoid using pipes in git related
    commands
    
    Changes since v1:
    
     * Merged patch [1/2] and [2/2] into a single patch
     * Revised commit message
    
    Signed-off-by: Amanda Shafack shafack.likhene@gmail.com
    [shafack.likhene@gmail.com]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-885%2Flkmandy%2Favoid-pipes-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-885/lkmandy/avoid-pipes-v2
Pull-Request: https://github.com/git/git/pull/885

Range-diff vs v1:

 1:  fc2da014a6 ! 1:  bca393e69a t9832,t2200: avoid using pipes in git commands
     @@ Metadata
       ## Commit message ##
          t9832,t2200: avoid using pipes in git commands
      
     -    When the upstream of a pipe throws an error, the downstream still
     -    executes normally. This happens because the exit code of the upstream
     -    in a pipe is ignored. This behavior can make debugging very hard
     -    incase a test fails. Also, pipes are prone to deadlocks. If the
     -    upstream gets full, the commands downstream will never start.
     +    When a git command is upstream in a pipe, an unexpected failure of
     +    the git command will go unnoticed.
      
     -    Write out the output of the git command to a file, so as to test the
     -    exit codes of both commands.
     -
     -    Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that
     -    the exit code of upstream in the pipe is ignored, thus using pipes
     -    should be avoided.
     +    Write out the output of the git command to a file, so as to actively
     +    catch a failure of the git command.
      
          Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
      
     @@ t/t2200-add-update.sh: test_expect_success 'add -u resolves unmerged paths' '
       test_expect_success '"add -u non-existent" should fail' '
       	test_must_fail git add -u non-existent &&
      -	! (git ls-files | grep "non-existent")
     -+	! (
     -+		git ls-files >actual &&
     -+		grep "non-existent" actual
     -+	)
     ++	git ls-files >actual &&
     ++	! grep "non-existent" actual
       '
       
       test_done
 2:  0a1550cb22 < -:  ---------- t2200: modify code syntax


 t/t2200-add-update.sh | 3 ++-
 t/t9832-unshelve.sh   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index f764b7e3f5..7cb7a70382 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -179,7 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 test_expect_success '"add -u non-existent" should fail' '
 	test_must_fail git add -u non-existent &&
-	! (git ls-files | grep "non-existent")
+	git ls-files >actual &&
+	! grep "non-existent" actual
 '
 
 test_done
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index 7194fb2855..6b3cb0414a 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -68,7 +68,8 @@ EOF
 		cd "$git" &&
 		change=$(last_shelved_change) &&
 		git p4 unshelve $change &&
-		git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
+		git show refs/remotes/p4-unshelved/$change >actual &&
+		grep -q "Further description" actual &&
 		git cherry-pick refs/remotes/p4-unshelved/$change &&
 		test_path_is_file file2 &&
 		test_cmp file1 "$cli"/file1 &&

base-commit: a5fa49ff0a8f3252c6bff49f92b85e7683868f8a
-- 
gitgitgadget

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

* Re: [PATCH v2] t9832,t2200: avoid using pipes in git commands
  2020-10-18 14:42 ` [PATCH v2] t9832,t2200: avoid using pipes in git commands Amanda  Shafack  via GitGitGadget
@ 2020-10-18 19:25   ` Eric Sunshine
  2020-10-18 20:04     ` Junio C Hamano
  2020-10-18 20:40     ` Amanda Shafack
  2020-10-18 20:48   ` [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe Amanda  Shafack  via GitGitGadget
  1 sibling, 2 replies; 14+ messages in thread
From: Eric Sunshine @ 2020-10-18 19:25 UTC (permalink / raw)
  To: Amanda Shafack via GitGitGadget
  Cc: Git List, Emily Shaffer, Jonathan Nieder, Amanda Shafack

On Sun, Oct 18, 2020 at 10:42 AM Amanda Shafack via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> t9832,t2200: avoid using pipes in git commands

The subject is a bit confusing since pipes aren't used in Git
commands; instead, Git commands may be components of pipes. However,
even that is too imprecise. The issue this patch is addressing is that
we want to avoid Git commands _upstream_ in a pipe. It's perfectly
acceptable for the Git command to be the final element of a pipe since
the pipe returns the exit code of the final command. So, to be more
precise, the subject could say:

    t2200,t9832: avoid using `git` upstream in a pipe

Nit: It's subjective, but it feels a bit more natural to list the test
numbers in ascending order rather than descending order, which is why
I swapped them around in the example above.

> When a git command is upstream in a pipe, an unexpected failure of
> the git command will go unnoticed.
>
> Write out the output of the git command to a file, so as to actively
> catch a failure of the git command.

It's easy to see from the patch itself that the output of the Git
command is now written to a file, so it's not necessary to say so in
the commit message. Therefore, the entire body of the commit message
could be written more succinctly, perhaps like this:

    Avoid placing `git` upstream in a pipe since doing so throws away
    its exit code, thus an unexpected failure may go unnoticed.

The actual patch itself looks fine, and these comments about the
commit message are quite minor, thus there probably is no need to
re-roll (though feel free to do so if you think the bit of extra
polishing of the commit message is worthwhile).

Thanks.

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

* Re: [PATCH v2] t9832,t2200: avoid using pipes in git commands
  2020-10-18 19:25   ` Eric Sunshine
@ 2020-10-18 20:04     ` Junio C Hamano
  2020-10-18 22:04       ` Amanda Shafack
  2020-10-18 20:40     ` Amanda Shafack
  1 sibling, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2020-10-18 20:04 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Amanda Shafack via GitGitGadget, Git List, Emily Shaffer,
	Jonathan Nieder, Amanda Shafack

Eric Sunshine <sunshine@sunshineco.com> writes:

> precise, the subject could say:
>
>     t2200,t9832: avoid using `git` upstream in a pipe
>
> Nit: It's subjective, but it feels a bit more natural to list the test
> numbers in ascending order rather than descending order, which is why
> I swapped them around in the example above.

;-)

>> When a git command is upstream in a pipe, an unexpected failure of
>> the git command will go unnoticed.
>>
>> Write out the output of the git command to a file, so as to actively
>> catch a failure of the git command.
>
> It's easy to see from the patch itself that the output of the Git
> command is now written to a file, so it's not necessary to say so in
> the commit message. Therefore, the entire body of the commit message
> could be written more succinctly, perhaps like this:
>
>     Avoid placing `git` upstream in a pipe since doing so throws away
>     its exit code, thus an unexpected failure may go unnoticed.

Yup.

> The actual patch itself looks fine, and these comments about the
> commit message are quite minor, thus there probably is no need to
> re-roll (though feel free to do so if you think the bit of extra
> polishing of the commit message is worthwhile).

IIUC, the microproject experience aims new contributors to get used
to the style of communication that happens during review cycles of a
typical topic, using a trivial dip-the-toes-in-the-water problem as
an example.  I'd rather not to see contributors get into the habit
of leaving loose ends and have somebody else clean after them.

Thanks.


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

* Re: [PATCH v2] t9832,t2200: avoid using pipes in git commands
  2020-10-18 19:25   ` Eric Sunshine
  2020-10-18 20:04     ` Junio C Hamano
@ 2020-10-18 20:40     ` Amanda Shafack
  1 sibling, 0 replies; 14+ messages in thread
From: Amanda Shafack @ 2020-10-18 20:40 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Amanda Shafack via GitGitGadget, Git List, Emily Shaffer,
	Jonathan Nieder

On Sun, Oct 18, 2020 at 8:25 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Sun, Oct 18, 2020 at 10:42 AM Amanda Shafack via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > t9832,t2200: avoid using pipes in git commands
>
> The subject is a bit confusing since pipes aren't used in Git
> commands; instead, Git commands may be components of pipes. However,
> even that is too imprecise. The issue this patch is addressing is that
> we want to avoid Git commands _upstream_ in a pipe. It's perfectly
> acceptable for the Git command to be the final element of a pipe since
> the pipe returns the exit code of the final command. So, to be more
> precise, the subject could say:
>
>     t2200,t9832: avoid using `git` upstream in a pipe
>
> Nit: It's subjective, but it feels a bit more natural to list the test
> numbers in ascending order rather than descending order, which is why
> I swapped them around in the example above.
>

I agree it looks more appropriate.

> > When a git command is upstream in a pipe, an unexpected failure of
> > the git command will go unnoticed.
> >
> > Write out the output of the git command to a file, so as to actively
> > catch a failure of the git command.
>
> It's easy to see from the patch itself that the output of the Git
> command is now written to a file, so it's not necessary to say so in
> the commit message. Therefore, the entire body of the commit message
> could be written more succinctly, perhaps like this:
>
>     Avoid placing `git` upstream in a pipe since doing so throws away
>     its exit code, thus an unexpected failure may go unnoticed.
>
> The actual patch itself looks fine, and these comments about the
> commit message are quite minor, thus there probably is no need to
> re-roll (though feel free to do so if you think the bit of extra
> polishing of the commit message is worthwhile).

I believe it's best practice to optimize one's work as much as
possible, so I have included these changes.
Thanks for the detailed explanation.

> Thanks.



-- 

Cheers!

Amanda  Shafack

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

* [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe
  2020-10-18 14:42 ` [PATCH v2] t9832,t2200: avoid using pipes in git commands Amanda  Shafack  via GitGitGadget
  2020-10-18 19:25   ` Eric Sunshine
@ 2020-10-18 20:48   ` Amanda  Shafack  via GitGitGadget
  2020-10-18 21:01     ` Junio C Hamano
  1 sibling, 1 reply; 14+ messages in thread
From: Amanda  Shafack  via GitGitGadget @ 2020-10-18 20:48 UTC (permalink / raw)
  To: git
  Cc: Emily Shaffer, Jonathan Nieder, Eric Sunshine, Amanda Shafack,
	Amanda Shafack, Amanda Shafack

From: Amanda Shafack <shafack.likhene@gmail.com>

Avoid placing `git` upstream in a pipe since doing so throws away
its exit code, thus an unexpected failure may go unnoticed.

Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
---
    [Outreachy][Patch v3] t2200,t9832: avoid using 'git' upstream in a pipe
    
    Changes since v2:
    
     * Optimized commit message
    
    Signed-off-by: Amanda Shafack shafack.likhene@gmail.com
    [shafack.likhene@gmail.com]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-885%2Flkmandy%2Favoid-pipes-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-885/lkmandy/avoid-pipes-v3
Pull-Request: https://github.com/git/git/pull/885

Range-diff vs v2:

 1:  bca393e69a ! 1:  d5f508b055 t9832,t2200: avoid using pipes in git commands
     @@ Metadata
      Author: Amanda Shafack <shafack.likhene@gmail.com>
      
       ## Commit message ##
     -    t9832,t2200: avoid using pipes in git commands
     +    t2200,t9832: avoid using 'git' upstream in a pipe
      
     -    When a git command is upstream in a pipe, an unexpected failure of
     -    the git command will go unnoticed.
     -
     -    Write out the output of the git command to a file, so as to actively
     -    catch a failure of the git command.
     +    Avoid placing `git` upstream in a pipe since doing so throws away
     +    its exit code, thus an unexpected failure may go unnoticed.
      
          Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
      


 t/t2200-add-update.sh | 3 ++-
 t/t9832-unshelve.sh   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index f764b7e3f5..7cb7a70382 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -179,7 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 test_expect_success '"add -u non-existent" should fail' '
 	test_must_fail git add -u non-existent &&
-	! (git ls-files | grep "non-existent")
+	git ls-files >actual &&
+	! grep "non-existent" actual
 '
 
 test_done
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index 7194fb2855..6b3cb0414a 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -68,7 +68,8 @@ EOF
 		cd "$git" &&
 		change=$(last_shelved_change) &&
 		git p4 unshelve $change &&
-		git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
+		git show refs/remotes/p4-unshelved/$change >actual &&
+		grep -q "Further description" actual &&
 		git cherry-pick refs/remotes/p4-unshelved/$change &&
 		test_path_is_file file2 &&
 		test_cmp file1 "$cli"/file1 &&

base-commit: a5fa49ff0a8f3252c6bff49f92b85e7683868f8a
-- 
gitgitgadget

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

* Re: [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe
  2020-10-18 20:48   ` [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe Amanda  Shafack  via GitGitGadget
@ 2020-10-18 21:01     ` Junio C Hamano
  0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2020-10-18 21:01 UTC (permalink / raw)
  To: Amanda Shafack via GitGitGadget
  Cc: git, Emily Shaffer, Jonathan Nieder, Eric Sunshine, Amanda Shafack

"Amanda  Shafack  via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Amanda Shafack <shafack.likhene@gmail.com>
>
> Avoid placing `git` upstream in a pipe since doing so throws away
> its exit code, thus an unexpected failure may go unnoticed.

Well explained.

> Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
> ---



> diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
> index f764b7e3f5..7cb7a70382 100755
> --- a/t/t2200-add-update.sh
> +++ b/t/t2200-add-update.sh
> @@ -179,7 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' '
>  
>  test_expect_success '"add -u non-existent" should fail' '
>  	test_must_fail git add -u non-existent &&
> -	! (git ls-files | grep "non-existent")
> +	git ls-files >actual &&
> +	! grep "non-existent" actual
>  '

In the scope of this patch, the above change is a good rewrite.
Let's stop the iteration here---you've demonstrated through the
microproject that you can now comfortably be involved in the review
discussion.

In a larger scope of "can we write this particular line better?",
however, the above may not be the _best_ answer.  For example,

	test_must_fail git ls-files --error-unmatch non-existent

would be another and a more direct way to ensure that the named path
does not appear in the index.

Thanks.

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

* Re: [PATCH v2] t9832,t2200: avoid using pipes in git commands
  2020-10-18 20:04     ` Junio C Hamano
@ 2020-10-18 22:04       ` Amanda Shafack
  0 siblings, 0 replies; 14+ messages in thread
From: Amanda Shafack @ 2020-10-18 22:04 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Eric Sunshine, Amanda Shafack via GitGitGadget, Git List,
	Emily Shaffer, Jonathan Nieder

On Sun, Oct 18, 2020 at 9:04 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
> > precise, the subject could say:
> >
> >     t2200,t9832: avoid using `git` upstream in a pipe
> >
> > Nit: It's subjective, but it feels a bit more natural to list the test
> > numbers in ascending order rather than descending order, which is why
> > I swapped them around in the example above.
>
> ;-)
>
> >> When a git command is upstream in a pipe, an unexpected failure of
> >> the git command will go unnoticed.
> >>
> >> Write out the output of the git command to a file, so as to actively
> >> catch a failure of the git command.
> >
> > It's easy to see from the patch itself that the output of the Git
> > command is now written to a file, so it's not necessary to say so in
> > the commit message. Therefore, the entire body of the commit message
> > could be written more succinctly, perhaps like this:
> >
> >     Avoid placing `git` upstream in a pipe since doing so throws away
> >     its exit code, thus an unexpected failure may go unnoticed.
>
> Yup.
>
> > The actual patch itself looks fine, and these comments about the
> > commit message are quite minor, thus there probably is no need to
> > re-roll (though feel free to do so if you think the bit of extra
> > polishing of the commit message is worthwhile).
>
> IIUC, the microproject experience aims new contributors to get used
> to the style of communication that happens during review cycles of a
> typical topic, using a trivial dip-the-toes-in-the-water problem as
> an example.  I'd rather not to see contributors get into the habit
> of leaving loose ends and have somebody else clean after them.

Taken very seriously

> Thanks.


-- 

Cheers!

Amanda  Shafack

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

end of thread, back to index

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 16:02 [PATCH 0/2] [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commands Amanda  Shafack  via GitGitGadget
2020-10-17 16:02 ` [PATCH 1/2] t9832,t2200: avoid using pipes in git commands Amanda Shafack via GitGitGadget
2020-10-18  6:11   ` Eric Sunshine
2020-10-18 13:57     ` Amanda Shafack
2020-10-17 16:02 ` [PATCH 2/2] t2200: modify code syntax Amanda  Shafack via GitGitGadget
2020-10-18  5:55   ` Eric Sunshine
2020-10-18 13:59     ` Amanda Shafack
2020-10-18 14:42 ` [PATCH v2] t9832,t2200: avoid using pipes in git commands Amanda  Shafack  via GitGitGadget
2020-10-18 19:25   ` Eric Sunshine
2020-10-18 20:04     ` Junio C Hamano
2020-10-18 22:04       ` Amanda Shafack
2020-10-18 20:40     ` Amanda Shafack
2020-10-18 20:48   ` [PATCH v3] t2200,t9832: avoid using 'git' upstream in a pipe Amanda  Shafack  via GitGitGadget
2020-10-18 21:01     ` Junio C Hamano

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git