On Wed, Jan 25, 2017 at 2:03 PM, Jonathan Tan <jonathanta...@google.com> wrote:
> In fetch-pack, during a stateless RPC, printf is invoked after stdout is
> closed. Update the code to not do this, preserving the existing
> behavior.

This seems to me as if it could go as an independent
bugfix(?) or refactoring as this seems to be unclear from the code?

>
> Signed-off-by: Jonathan Tan <jonathanta...@google.com>
> ---
>  builtin/fetch-pack.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
> index ae073ab24..24af3b7c5 100644
> --- a/builtin/fetch-pack.c
> +++ b/builtin/fetch-pack.c
> @@ -191,10 +191,10 @@ int cmd_fetch_pack(int argc, const char **argv, const 
> char *prefix)
>                 printf("connectivity-ok\n");
>                 fflush(stdout);
>         }
> -       close(fd[0]);
> -       close(fd[1]);
> -       if (finish_connect(conn))
> -               return 1;
> +       if (finish_connect(conn)) {
> +               ret = 1;
> +               goto cleanup;
> +       }
>
>         ret = !ref;
>
> @@ -218,11 +218,17 @@ int cmd_fetch_pack(int argc, const char **argv, const 
> char *prefix)
>                 ret = 1;
>         }
>
> +       if (args.stateless_rpc)
> +               goto cleanup;
> +
>         while (ref) {
>                 printf("%s %s\n",
>                        oid_to_hex(&ref->old_oid), ref->name);
>                 ref = ref->next;
>         }
>
> +cleanup:
> +       close(fd[0]);
> +       close(fd[1]);
>         return ret;
>  }
> --
> 2.11.0.483.g087da7b7c-goog
>

Reply via email to