threads / patch / 51033

patcht4253-am-keep-cr-dos: avoid using pipes

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

## tl;dr

2 messages between May 5, 2019 and May 5, 2019. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Boxuan Li· May 5, 2019, 02:38 UTC · lore

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.

Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
---
 t/t4253-am-keep-cr-dos.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to t/t4253-am-keep-cr-dos.sh +4 −2
diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh
index 553fe3e88e..5408c23dca 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 > actual &&
+	git am --keep-cr -k -3 actual &&
 	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 > actual &&
+	git am -k -3 actual &&
 	git diff --exit-code master
 '
 
-- 
2.21.0.777.g83232e3864
Eric Sunshine· May 5, 2019, 06:32 UTC · re: Boxuan Li · lore

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

On Sat, May 4, 2019 at 10:39 PM Boxuan Li <liboxuan@connect.hku.hk> wrote:
Show 13 quoted lines
> 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.
>
> Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
> ---
> diff --git 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 > actual &&
> +       git am --keep-cr -k -3 actual &&

Style nit: In this codebase, the space is omitted after the redirection operator (i.e. >actual).

Nit: Given that the name "actual" is typically used in conjunction
with an "expect" (or "expected") file, its use here is somewhat
unexpected. Other possible names which might be more meaningful
include "patches" and "output".
>         git diff --exit-code master
>  '

← back to recent threads