diff mbox series

[3/3] diff --submodule=diff: Don't print failure message twice

Message ID 20210726183358.3255233-3-dturner@twosigma.com (mailing list archive)
State Superseded
Headers show
Series [1/3] Remove unused var | expand

Commit Message

David Turner July 26, 2021, 6:33 p.m. UTC
When we fail to start a diff command inside a submodule, immediately
exit the routine rather than trying to finish the command and printing
a second message.

Signed-off-by: David Turner <dturner@twosigma.com>
---
 submodule.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Junio C Hamano July 26, 2021, 10:47 p.m. UTC | #1
David Turner <dturner@twosigma.com> writes:

> When we fail to start a diff command inside a submodule, immediately
> exit the routine rather than trying to finish the command and printing
> a second message.
>
> Signed-off-by: David Turner <dturner@twosigma.com>
> ---
>  submodule.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/submodule.c b/submodule.c
> index 9031527a16..0acfad3d4c 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -713,8 +713,10 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
>  		strvec_push(&cp.args, oid_to_hex(new_oid));
>  
>  	prepare_submodule_repo_env(&cp.env_array);
> -	if (start_command(&cp))
> +	if (start_command(&cp)) {
>  		diff_emit_submodule_error(o, "(diff failed)\n");
> +		goto done;
> +	}
>  
>  	while (strbuf_getwholeline_fd(&sb, cp.out, '\n') != EOF)
>  		diff_emit_submodule_pipethrough(o, sb.buf, sb.len);

Again, makes sense.  Thanks.
diff mbox series

Patch

diff --git a/submodule.c b/submodule.c
index 9031527a16..0acfad3d4c 100644
--- a/submodule.c
+++ b/submodule.c
@@ -713,8 +713,10 @@  void show_submodule_inline_diff(struct diff_options *o, const char *path,
 		strvec_push(&cp.args, oid_to_hex(new_oid));
 
 	prepare_submodule_repo_env(&cp.env_array);
-	if (start_command(&cp))
+	if (start_command(&cp)) {
 		diff_emit_submodule_error(o, "(diff failed)\n");
+		goto done;
+	}
 
 	while (strbuf_getwholeline_fd(&sb, cp.out, '\n') != EOF)
 		diff_emit_submodule_pipethrough(o, sb.buf, sb.len);