diff options
author | Petr Baudis <pasky@suse.cz> | 2006-07-27 23:56:19 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-07-27 19:33:48 -0700 |
commit | 8e87ca661513d9f4b737295b234e93767cd2ee0c (patch) | |
tree | c757f0a8288533617c3ef5d1f31570fbd7e561c0 /fetch.c | |
parent | 4211e4d10cd98b1aeed97bdb6cdebb9411956bb5 (diff) | |
download | git-8e87ca661513d9f4b737295b234e93767cd2ee0c.tar.gz |
Teach git-local-fetch the --stdin switch
This makes it possible to fetch many commits (refs) at once, greatly
speeding up cg-clone.
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'fetch.c')
-rw-r--r-- | fetch.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -7,6 +7,7 @@ #include "tag.h" #include "blob.h" #include "refs.h" +#include "strbuf.h" int get_tree = 0; int get_history = 0; @@ -210,6 +211,45 @@ static int mark_complete(const char *path, const unsigned char *sha1) return 0; } +int pull_targets_stdin(char ***target, const char ***write_ref) +{ + int targets = 0, targets_alloc = 0; + struct strbuf buf; + *target = NULL; *write_ref = NULL; + strbuf_init(&buf); + while (1) { + char *rf_one = NULL; + char *tg_one; + + read_line(&buf, stdin, '\n'); + if (buf.eof) + break; + tg_one = buf.buf; + rf_one = strchr(tg_one, '\t'); + if (rf_one) + *rf_one++ = 0; + + if (targets >= targets_alloc) { + targets_alloc = targets_alloc ? targets_alloc * 2 : 64; + *target = xrealloc(*target, targets_alloc * sizeof(**target)); + *write_ref = xrealloc(*write_ref, targets_alloc * sizeof(**write_ref)); + } + (*target)[targets] = strdup(tg_one); + (*write_ref)[targets] = rf_one ? strdup(rf_one) : NULL; + targets++; + } + return targets; +} + +void pull_targets_free(int targets, char **target, const char **write_ref) +{ + while (targets--) { + free(target[targets]); + if (write_ref[targets]) + free((char *) write_ref[targets]); + } +} + int pull(int targets, char **target, const char **write_ref, const char *write_ref_log_details) { |