summaryrefslogtreecommitdiff
path: root/transport-helper.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2009-09-03 22:13:51 -0400
committerJunio C Hamano <gitster@pobox.com>2009-09-03 21:27:36 -0700
commit2d14d65ce7b136b0fb18dcf27e5caff67829f658 (patch)
tree8b0424fe24b752d2937b8c996f98198cc2ba78a7 /transport-helper.c
parentc9e388bb48bdafdf19574add915ab0ce33a1907d (diff)
downloadgit-2d14d65ce7b136b0fb18dcf27e5caff67829f658.tar.gz
Use a clearer style to issue commands to remote helpers
This style is overkill for some commands, but it's worthwhile to use the same style to issue all commands, and it's useful to avoid open-coding string lengths. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r--transport-helper.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/transport-helper.c b/transport-helper.c
index 4684877723..b1ea7e6f40 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -37,7 +37,10 @@ static struct child_process *get_helper(struct transport *transport)
die("Unable to run helper: git %s", helper->argv[0]);
data->helper = helper;
- write_in_full(data->helper->in, "capabilities\n", 13);
+ strbuf_addstr(&buf, "capabilities\n");
+ write_in_full(helper->in, buf.buf, buf.len);
+ strbuf_reset(&buf);
+
file = fdopen(helper->out, "r");
while (1) {
if (strbuf_getline(&buf, file, '\n') == EOF)
@@ -78,11 +81,12 @@ static int fetch_with_fetch(struct transport *transport,
const struct ref *posn = to_fetch[i];
if (posn->status & REF_STATUS_UPTODATE)
continue;
- write_in_full(helper->in, "fetch ", 6);
- write_in_full(helper->in, sha1_to_hex(posn->old_sha1), 40);
- write_in_full(helper->in, " ", 1);
- write_in_full(helper->in, posn->name, strlen(posn->name));
- write_in_full(helper->in, "\n", 1);
+
+ strbuf_addf(&buf, "fetch %s %s\n",
+ sha1_to_hex(posn->old_sha1), posn->name);
+ write_in_full(helper->in, buf.buf, buf.len);
+ strbuf_reset(&buf);
+
if (strbuf_getline(&buf, file, '\n') == EOF)
exit(128); /* child died, message supplied already */
}
@@ -119,7 +123,10 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
FILE *file;
helper = get_helper(transport);
- write_in_full(helper->in, "list\n", 5);
+
+ strbuf_addstr(&buf, "list\n");
+ write_in_full(helper->in, buf.buf, buf.len);
+ strbuf_reset(&buf);
file = fdopen(helper->out, "r");
while (1) {