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

Re: [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes

From
LI, BO XUAN <liboxuan@connect.hku.hk>
Date
May 7, 2019, 12:42 UTC
Message-ID
<CALM0=-=5WeTJ2-r+u-8TYzOAih_3aCEESSpA4oKhxjRpK2yj6w@mail.gmail.com>
In-Reply-To
<xmqqy33iljo8.fsf@gitster-ct.c.googlers.com>
Hi Junio,

Thanks for your review! I can understand your point, but I've got a quick question:

What if format-patch really breaks and 'am' magically does not break? Then the two tests might still pass. On the contrary, with this patch, we can verify the correctness of format-patch and safely rely on it.

Best regards, Boxuan Li

On Tue, May 7, 2019 at 5:04 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 49 quoted lines
>
> Boxuan Li <liboxuan@connect.hku.hk> writes:
>
> > The exit code of the upstream in a pipe is ignored thus we should avoid
> > using it. By writing out the output of the git command to a file, we can
> > test the exit codes of both the commands.
>
> We are trying to catch breakages in "am" in these two tests (see the
> title of the test file), and we rely on format-patch to correctly
> produce its output---if we assume that the command being tested,
> i.e. "am", could be fed garbage, the tests become pointless.
>
> And once we decide to rely on the correctness of format-patch in
> these two tests, there no longer is a reason to fear that
> invocations of it upstream of a pipe would lose the exit status.
>
> So while the patch is not wrong per-se, but these two changes are
> borderline Meh.
>
> > Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
> > ---
> > Thanks to Eric Sunshine's review, I've removed spaces after '>'
> > and changed 'actual' into 'output'.
> > ---
> >  t/t4253-am-keep-cr-dos.sh | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh
> > index 553fe3e88e..6e1b73ec3a 100755
> > --- a/t/t4253-am-keep-cr-dos.sh
> > +++ b/t/t4253-am-keep-cr-dos.sh
> > @@ -51,14 +51,16 @@ test_expect_success 'am with dos files without --keep-cr' '
> >
> >  test_expect_success 'am with dos files with --keep-cr' '
> >       git checkout -b dosfiles-keep-cr initial &&
> > -     git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&
> > +     git format-patch -k --stdout initial..master >output &&
> > +     git am --keep-cr -k -3 output &&
> >       git diff --exit-code master
> >  '
> >
> >  test_expect_success 'am with dos files config am.keepcr' '
> >       git config am.keepcr 1 &&
> >       git checkout -b dosfiles-conf-keepcr initial &&
> > -     git format-patch -k --stdout initial..master | git am -k -3 &&
> > +     git format-patch -k --stdout initial..master >output &&
> > +     git am -k -3 output &&
> >       git diff --exit-code master
> >  '
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “t4253-am-keep-cr-dos: avoid using pipes”
  1. t4253-am-keep-cr-dos: avoid using pipesBoxuan Li, May 5, 2019
  2. Junio C HamanoMay 7, 2019
  3. LI, BO XUANMay 7, 2019
  4. Junio C HamanoMay 8, 2019
  5. LI, BO XUANMay 8, 2019

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.