summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9e388b)
raw | patch | inline | side by side (parent: c9e388b)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Fri, 4 Sep 2009 02:13:51 +0000 (22:13 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Sep 2009 04:27:36 +0000 (21:27 -0700) |
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>
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>
transport-helper.c | patch | blob | history |
diff --git a/transport-helper.c b/transport-helper.c
index 46848777233c31b12897cf06ecf71e1718b342c1..b1ea7e6f40d94822f2e146cd9c615f607aa11d77 100644 (file)
--- a/transport-helper.c
+++ b/transport-helper.c
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)
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 */
}
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) {