path: root/commit.c
diff options
authorShawn O. Pearce <>2009-10-31 00:47:23 (GMT)
committerJunio C Hamano <>2009-10-31 02:20:53 (GMT)
commitedace6f02eeae6f4a06ed1e4f6308703523d8535 (patch)
tree6d9b04955335bca0703fee906764720f353afa72 /commit.c
parent743c4b7b0fa5422d1bb5dc59c6cb919a881dd98b (diff)
fetch-pack: Use a strbuf to compose the want list
This change is being offered as a refactoring to make later commits in the smart HTTP series easier. By changing the enabled capabilities to be formatted in a strbuf it is easier to add a new capability to the set of supported capabilities. By formatting the want portion of the request into a strbuf and writing it as a whole block we can later decide to hold onto the req_buf (instead of releasing it) to recycle in stateless communications. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 4 insertions, 6 deletions
diff --git a/commit.c b/commit.c
index fedbd5e..471efb05 100644
--- a/commit.c
+++ b/commit.c
@@ -199,7 +199,7 @@ struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
return commit_graft[pos];
-int write_shallow_commits(int fd, int use_pack_protocol)
+int write_shallow_commits(struct strbuf *out, int use_pack_protocol)
int i, count = 0;
for (i = 0; i < commit_graft_nr; i++)
@@ -208,12 +208,10 @@ int write_shallow_commits(int fd, int use_pack_protocol)
if (use_pack_protocol)
- packet_write(fd, "shallow %s", hex);
+ packet_buf_write(out, "shallow %s", hex);
else {
- if (write_in_full(fd, hex, 40) != 40)
- break;
- if (write_str_in_full(fd, "\n") != 1)
- break;
+ strbuf_addstr(out, hex);
+ strbuf_addch(out, '\n');
return count;