git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commands

From
Chizoba ODINAKA <chizobajames21@gmail.com>
Date
Oct 10, 2024, 18:51 UTC
Message-ID
<CACwP9aqEoRchNN-4iuSxrhtt5k-yHMsjmyQjaG9uV4xUsQ7geg@mail.gmail.com>
In-Reply-To
<90dea722-0762-4a37-a216-6883f4889c67@gmail.com>

Hi Philip, On Thu, 10 Oct 2024 at 15:08, Phillip Wood <phillip.wood123@gmail.com> wrote:

Show 13 quoted lines
>
> Hi Chizoba
>
> On 10/10/2024 07:39, chizobajames21@gmail.com wrote:
> > From: Chizoba ODINAKA <chizobajames21@gmail.com>
> >
> > In pipes, the exit code of a chain of commands is determined by
> > the downstream command.
>
> I would perhaps say "final command" rather than "downstream command" as
> in a pipeline "cmd1 | cmd2 | cmd3" cmd2 and cmd3 are downstream of cmd1
> but it is the exit code of cmd3 that will be used
>
Yes, final command is a more appropriate explain.
Show 7 quoted lines
> > In order not to loss the entire result code of tests,
> > write output of upstreams into a file.
>
> We're interested in checking the exit code of git, but not other
> commands so it would be helpful to make that clear. Usman's patch [1]
> has a good explanation of this.
>

I just read that sentence again, it obviously needs some clarity. "In order not to miss the exit code of any Git command, avoid using pipe and write output into a file" has more clarity. I will look up on Usman's patch [1], before my next changes.

> This patch also changes instances of "grep" to "test_grep" so the commit
> message needs to explain the reason for that change which is that it
> gives a better debugging experience if the test fails.
>
I had included that in my "Changes in v2", appended beneath my "Sign-off-by".
"Changes in v2:
- split multiple commands chain on the same line across multiple line,
  for easier readability
- replace "grep" with "test_grep", for more context in case of a "grep"
  failure"
Maybe it was not so obvious that you didn't notice, or it is not the
traditional way of including it.
Show 64 quoted lines
> The patch is looking pretty good, most of the conversions look correct.
> I've left a few comments below
>
>
> [1]
> https://lore.kernel.org/git/bfff7937cd20737bb5a8791dc7492700b1d7881f.1728315124.git.gitgitgadget@gmail.com
>
> >   test_expect_success 'replace the author' '
> > -     git cat-file commit $HASH2 | grep "author A U Thor" &&
> > -     R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
> > -     git cat-file commit $R | grep "author O Thor" &&
> > +     git cat-file commit $HASH2 >actual &&
> > +     test_grep "author A U Thor" actual &&
> > +     git cat-file commit $HASH2 >actual &&
>
> You don't need to repeat this command now that we are saving the output
> of "git cat-file commit $HASH2"
>
> > +     R=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
> > +     git cat-file commit $R >actual &&
> > +     test_grep "author O Thor" actual &&
>
> >   test_expect_success 'push branch with replacement' '
> > -     git cat-file commit $PARA3 | grep "author A U Thor" &&
> > -     S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
> > -     git cat-file commit $S | grep "author O Thor" &&
> > +     git cat-file commit $PARA3 >actual &&
> > +     test_grep "author A U Thor" actual &&
> > +     git cat-file commit $PARA3 >actual &&
>
> We can drop this line for the same reason as above
>
> > +     S=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
> > +     git cat-file commit $S >actual &&
> > +     test_grep "author O Thor" actual &&
>
> > @@ -260,14 +291,14 @@ test_expect_success 'fetch branch with replacement' '
> >               cd clone_dir &&
> >               git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
> >               git log --pretty=oneline parallel3 >output.txt &&
> > -             ! grep $PARA3 output.txt &&
> > +             ! test_grep $PARA3 output.txt &&
>
> test_grep will print an error message the pattern does not match. In
> this case we expect it not to match so we want to print an error if it
> does match. We can do that with
>
>         test_grep ! $PARA3 output.txt &&
>
> >   test_expect_success 'index-pack and replacements' '
> > -     git --no-replace-objects rev-list --objects HEAD |
> > +     git --no-replace-objects rev-list --objects HEAD >actual &&
> >       git --no-replace-objects pack-objects test- &&
>
> This command has lost its input - you need to use '<actual' to get it to
> read output from "git rev-list". This test itself could probably do a
> better job of checking that index-pack does what we expect but that is
> outside the scope of this patch.
>
> >       git index-pack test-*.pack
> >   '
>
> Everything that I've not commented on looks correct to me.
>

Thanks Philip for the review, I will make the needed changes in my next patch. And look into the index-pack proposal in a new patch, since it is outside this scope.

> Best Wishes
>
> Phillip

Thanks Chizoba

Previous: Phillip WoodNext: phillip.wood123@gmail.com
Message 6 of 25 in “t6050: avoid pipes in git related commands”
  1. chizobajames21@gmail.comOct 8, 2024
  2. Patrick SteinhardtOct 9, 2024
  3. Chizoba ODINAKAOct 10, 2024
  4. [Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commandschizobajames21@gmail.com, Oct 10, 2024
  5. Phillip WoodOct 10, 2024
  6. Chizoba ODINAKAOct 10, 2024
  7. phillip.wood123@gmail.comOct 11, 2024
  8. [Outreachy][PATCH v3] t6050: avoid pipes with downstream Git commandschizobajames21@gmail.com, Oct 11, 2024
  9. Junio C HamanoOct 11, 2024
  10. Eric SunshineOct 11, 2024
  11. Junio C HamanoOct 11, 2024
  12. [Outreachy][PATCH v4] t6050: avoid pipes with upstream Git commandschizobajames21@gmail.com, Oct 11, 2024
  13. Eric SunshineOct 12, 2024
  14. Chizoba ODINAKAOct 12, 2024
  15. [Outreachy][PATCH v5] t6050: avoid pipes with upstream Git commandschizobajames21@gmail.com, Oct 12, 2024
  16. Phillip WoodOct 14, 2024
  17. Chizoba ODINAKAOct 14, 2024
  18. [Outreachy][PATCH v6] t6050: avoid pipes with upstream Git commandschizobajames21@gmail.com, Oct 14, 2024
  19. Taylor BlauOct 14, 2024
  20. Chizoba ODINAKAOct 15, 2024
  21. [Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commandschizobajames21@gmail.com, Oct 15, 2024
  22. [Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commandschizobajames21@gmail.com, Oct 22, 2024
  23. Chizoba ODINAKAOct 22, 2024
  24. Patrick SteinhardtOct 22, 2024
  25. Taylor BlauOct 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.