Thread (21 messages) 21 messages, 3 authors, 2017-02-08

Re: [RFC 12/14] fetch-pack: do not printf after closing stdout

flat view

From: Stefan Beller <hidden>
Date: 2017-01-26 00:50:17

On Wed, Jan 25, 2017 at 2:03 PM, Jonathan Tan [off-list ref] 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?
quoted hunk ↗ jump to hunk
Signed-off-by: Jonathan Tan <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help