X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin-remote.c;h=8b63619ef08a2ac3d96000908fe4986396ddd6a2;hb=634f246444e6a1675e351f31362e6a375dc44f70;hp=d77f10a0eaa64466b919bcede37ad8c67b70b3fc;hpb=eed81838f0d0e031702473e1d427d71055134edd;p=git.git diff --git a/builtin-remote.c b/builtin-remote.c index d77f10a0e..8b63619ef 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -19,6 +19,8 @@ static const char * const builtin_remote_usage[] = { static int verbose; +static int show_all(void); + static inline int postfixcmp(const char *string, const char *postfix) { int len1 = strlen(string), len2 = strlen(postfix); @@ -88,19 +90,24 @@ static int add(int argc, const char **argv) strbuf_init(&buf, 0); strbuf_init(&buf2, 0); + strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name); + if (!valid_fetch_refspec(buf2.buf)) + die("'%s' is not a valid remote name", name); + strbuf_addf(&buf, "remote.%s.url", name); if (git_config_set(buf.buf, url)) return 1; + strbuf_reset(&buf); + strbuf_addf(&buf, "remote.%s.fetch", name); + if (track.nr == 0) path_list_append("*", &track); for (i = 0; i < track.nr; i++) { struct path_list_item *item = track.items + i; - strbuf_reset(&buf); - strbuf_addf(&buf, "remote.%s.fetch", name); - strbuf_reset(&buf2); + strbuf_addch(&buf2, '+'); if (mirror) strbuf_addf(&buf2, "refs/%s:refs/%s", item->path, item->path); @@ -111,6 +118,13 @@ static int add(int argc, const char **argv) return 1; } + if (mirror) { + strbuf_reset(&buf); + strbuf_addf(&buf, "remote.%s.mirror", name); + if (git_config_set(buf.buf, "yes")) + return 1; + } + if (fetch && fetch_remote(name)) return 1; @@ -380,8 +394,11 @@ static int show_or_prune(int argc, const char **argv, int prune) argc = parse_options(argc, argv, options, builtin_remote_usage, 0); - if (argc < 1) + if (argc < 1) { + if (!prune) + return show_all(); usage_with_options(builtin_remote_usage, options); + } memset(&states, 0, sizeof(states)); for (; argc; argc--, argv++) {