aboutsummaryrefslogtreecommitdiff
path: root/builtin-fetch--tool.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-16 02:31:36 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-13 21:43:53 -0800
commitd1e0ef6cc89e5ef2f914c37719b9c2327e534834 (patch)
tree53a654d5b92eba36cdd510df5f0e601c813268e4 /builtin-fetch--tool.c
parentfbe2687eba70385dab7e3d1f5cdcdfdc11dfe0ec (diff)
downloadgit-d1e0ef6cc89e5ef2f914c37719b9c2327e534834.tar.gz
git-d1e0ef6cc89e5ef2f914c37719b9c2327e534834.tar.xz
git-fetch: rewrite another shell loop in C
Move another shell loop that canonicalizes the list of refs for underlying git-fetch-pack and fetch-native-store into C. This seems to shave the runtime for the same 1000 branch repository from 30 seconds down to 15 seconds (it used to be 2 and half minutes with the original version). Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-fetch--tool.c')
-rw-r--r--builtin-fetch--tool.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 24343ac9b..705a6649a 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -283,6 +283,46 @@ static int fetch_native_store(FILE *fp,
return err;
}
+static int parse_reflist(const char *reflist)
+{
+ const char *ref;
+
+ printf("refs='");
+ for (ref = reflist; ref; ) {
+ const char *next;
+ while (*ref && isspace(*ref))
+ ref++;
+ if (!*ref)
+ break;
+ for (next = ref; *next && !isspace(*next); next++)
+ ;
+ printf("\n%.*s", (int)(next - ref), ref);
+ ref = next;
+ }
+ printf("'\n");
+
+ printf("rref='");
+ for (ref = reflist; ref; ) {
+ const char *next, *colon;
+ while (*ref && isspace(*ref))
+ ref++;
+ if (!*ref)
+ break;
+ for (next = ref; *next && !isspace(*next); next++)
+ ;
+ if (*ref == '.')
+ ref++;
+ if (*ref == '+')
+ ref++;
+ colon = strchr(ref, ':');
+ putchar('\n');
+ printf("%.*s", (int)((colon ? colon : next) - ref), ref);
+ ref = next;
+ }
+ printf("'\n");
+ return 0;
+}
+
int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
{
int verbose = 0;
@@ -335,5 +375,11 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
fclose(fp);
return result;
}
+ if (!strcmp("parse-reflist", argv[1])) {
+ if (argc != 3)
+ return error("parse-reflist takes 1 arg");
+ return parse_reflist(argv[2]);
+ }
+
return error("Unknown subcommand: %s", argv[1]);
}