{"thread":{"id":"7972","subject":"Initial support for cloning submodules","startedAt":"2007-05-04T10:49:22Z","lastAt":"2007-05-06T13:53:06Z","messageCount":8,"participants":["Sven Verdoolaege","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"41042","messageId":"11782757671754-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":null,"subject":"Initial support for cloning submodules","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:22Z","receivedAt":"2007-05-04T10:49:22Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nThis patch series implements a mechanism for cloning submodules.\nEach submodule is specified by a 'submodule.<submodule>.url'\nconfiguration option, e.g.,\n\nbash-3.00$ ./git-config --remote=http://www.liacs.nl/~sverdool/isa.git --get-regexp 'submodule\\..*\\.url' \nsubmodule.cloog.url /home/sverdool/public_html/cloog.git\nsubmodule.cloog.url http://www.liacs.nl/~sverdool/cloog.git\n\ngit-clone will use the first url that works.\nE.g., a\n\ngit clone --submodules ssh://liacs/~/public_html/isa.git\n\n(which only works for me), will use the first url, while a\n\ngit clone --submodules http://www.liacs.nl/~sverdool/isa.git\n\nwill use the second.\n\nThe submodules are currently not checked out.\n\nskimo\n"},{"id":"41044","messageId":"11782757672063-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":"11782757671754-git-send-email-skimo@liacs.nl","subject":"[PATCH] Add dump-config","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:23Z","receivedAt":"2007-05-04T10:49:23Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nThis command dumps the config of a repository and will be used\nto read config options from a remote site.\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n---\n .gitignore                        |    1 +\n Documentation/cmd-list.perl       |    1 +\n Documentation/git-dump-config.txt |   37 +++++++++++++++++++++++++++++++++++++\n Makefile                          |    1 +\n daemon.c                          |    7 +++++++\n dump-config.c                     |   29 +++++++++++++++++++++++++++++\n 6 files changed, 76 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/git-dump-config.txt\n create mode 100644 dump-config.c\n\ndiff --git a/.gitignore b/.gitignore\nindex 4dc0c39..d4e5492 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -38,6 +38,7 @@ git-diff-files\n git-diff-index\n git-diff-tree\n git-describe\n+git-dump-config\n git-fast-import\n git-fetch\n git-fetch--tool\ndiff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl\nindex 443802a..fa04615 100755\n--- a/Documentation/cmd-list.perl\n+++ b/Documentation/cmd-list.perl\n@@ -103,6 +103,7 @@ git-diff-files                          plumbinginterrogators\n git-diff-index                          plumbinginterrogators\n git-diff                                mainporcelain\n git-diff-tree                           plumbinginterrogators\n+git-dump-config                         synchelpers\n git-fast-import\t\t\t\tancillarymanipulators\n git-fetch                               mainporcelain\n git-fetch-pack                          synchingrepositories\ndiff --git a/Documentation/git-dump-config.txt b/Documentation/git-dump-config.txt\nnew file mode 100644\nindex 0000000..370781c\n--- /dev/null\n+++ b/Documentation/git-dump-config.txt\n@@ -0,0 +1,37 @@\n+git-dump-config(1)\n+====================\n+\n+NAME\n+----\n+git-dump-config - Dump config options\n+\n+\n+SYNOPSIS\n+--------\n+'git-dump-config' <directory>\n+\n+DESCRIPTION\n+-----------\n+Invoked by 'git-config --remote' and dumps the config file to the\n+other end over the git protocol.\n+\n+This command is usually not invoked directly by the end user.  The UI\n+for the protocol is on the 'git-config' side, where it is used to get\n+options from a remote repository.\n+\n+OPTIONS\n+-------\n+<directory>::\n+\tThe repository to get the config options from.\n+\n+Author\n+------\n+Written by Sven Verdoolaege.\n+\n+Documentation\n+--------------\n+Documentation by Sven Verdoolaege.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\ndiff --git a/Makefile b/Makefile\nindex e0a1308..0185386 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -232,6 +232,7 @@ PROGRAMS = \\\n \tgit-fast-import$X \\\n \tgit-merge-base$X \\\n \tgit-daemon$X \\\n+\tgit-dump-config$X \\\n \tgit-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \\\n \tgit-peek-remote$X git-receive-pack$X \\\n \tgit-send-pack$X git-shell$X \\\ndiff --git a/daemon.c b/daemon.c\nindex e74ecac..3e5ebf3 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -378,10 +378,17 @@ static int receive_pack(void)\n \treturn -1;\n }\n \n+static int dump_config(void)\n+{\n+\texecl_git_cmd(\"dump-config\", \".\", NULL);\n+\treturn -1;\n+}\n+\n static struct daemon_service daemon_service[] = {\n \t{ \"upload-archive\", \"uploadarch\", upload_archive, 0, 1 },\n \t{ \"upload-pack\", \"uploadpack\", upload_pack, 1, 1 },\n \t{ \"receive-pack\", \"receivepack\", receive_pack, 0, 1 },\n+\t{ \"dump-config\", \"dumpconfig\", dump_config, 0, 1 },\n };\n \n static void enable_service(const char *name, int ena) {\ndiff --git a/dump-config.c b/dump-config.c\nnew file mode 100644\nindex 0000000..355920d\n--- /dev/null\n+++ b/dump-config.c\n@@ -0,0 +1,29 @@\n+#include \"git-compat-util.h\"\n+#include \"cache.h\"\n+#include \"pkt-line.h\"\n+\n+static const char dump_config_usage[] = \"git-dump-config <dir>\";\n+\n+static int dump_config(const char *var, const char *value)\n+{\n+\tpacket_write(1, \"%s\", var);\n+\tpacket_write(1, \"%s\", value);\n+\treturn 0;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tchar *dir;\n+\n+\tif (argc != 2)\n+\t\tusage(dump_config_usage);\n+\n+\tdir = argv[1];\n+\tif (!enter_repo(dir, 0))\n+\t\tdie(\"'%s': unable to chdir or not a git archive\", dir);\n+\n+\tgit_config(dump_config);\n+\tpacket_flush(1);\n+\n+\treturn 0;\n+}\n-- \n1.5.2.rc1.25.g889f-dirty\n"},{"id":"41047","messageId":"11782757672683-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":"11782757671754-git-send-email-skimo@liacs.nl","subject":"[PATCH] git-config: add --remote option for reading config from remote repo","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:24Z","receivedAt":"2007-05-04T10:49:24Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n---\n Documentation/git-config.txt |   33 +++++++++++++++++++++---------\n builtin-config.c             |   44 ++++++++++++++++++++++++++++++++---------\n cache.h                      |    1 +\n config.c                     |   26 ++++++++++++++++++++++++\n 4 files changed, 84 insertions(+), 20 deletions(-)\n\ndiff --git a/Documentation/git-config.txt b/Documentation/git-config.txt\nindex 280ef20..76398ab 100644\n--- a/Documentation/git-config.txt\n+++ b/Documentation/git-config.txt\n@@ -9,16 +9,25 @@ git-config - Get and set repository or global options\n SYNOPSIS\n --------\n [verse]\n-'git-config' [--system | --global] [type] name [value [value_regex]]\n-'git-config' [--system | --global] [type] --add name value\n-'git-config' [--system | --global] [type] --replace-all name [value [value_regex]]\n-'git-config' [--system | --global] [type] --get name [value_regex]\n-'git-config' [--system | --global] [type] --get-all name [value_regex]\n-'git-config' [--system | --global] [type] --unset name [value_regex]\n-'git-config' [--system | --global] [type] --unset-all name [value_regex]\n-'git-config' [--system | --global] [type] --rename-section old_name new_name\n-'git-config' [--system | --global] [type] --remove-section name\n-'git-config' [--system | --global] -l | --list\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] name [value [value_regex]]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --add name value\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --replace-all name [value [value_regex]]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --get name [value_regex]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --get-all name [value_regex]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --unset name [value_regex]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --unset-all name [value_regex]\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --rename-section old_name new_name\n+'git-config' [--system | --global | --remote=[<host>:]<directory ]\n+\t     [type] --remove-section name\n+'git-config' [--system | --global | --remote=[<host>:]<directory ] -l | --list\n \n DESCRIPTION\n -----------\n@@ -80,6 +89,10 @@ OPTIONS\n \tUse system-wide $(prefix)/etc/gitconfig rather than the repository\n \t.git/config.\n \n+--remote=[<host>:]<directory\n+\tUse remote config instead of the repository .git/config.\n+\tOnly available for reading options.\n+\n --remove-section::\n \tRemove the given section from the configuration file.\n \ndiff --git a/builtin-config.c b/builtin-config.c\nindex b2515f7..3a1e86c 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -2,8 +2,10 @@\n #include \"cache.h\"\n \n static const char git_config_set_usage[] =\n-\"git-config [ --global | --system ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list\";\n+\"git-config [ --global | --system | --remote=[<host>:]<directory ] \"\n+\"[ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list\";\n \n+static char *dest;\n static char *key;\n static regex_t *key_regexp;\n static regex_t *regexp;\n@@ -104,15 +106,19 @@ static int get_value(const char* key_, const char* regex_)\n \t\t}\n \t}\n \n-\tif (do_all && system_wide)\n-\t\tgit_config_from_file(show_config, system_wide);\n-\tif (do_all && global)\n-\t\tgit_config_from_file(show_config, global);\n-\tgit_config_from_file(show_config, local);\n-\tif (!do_all && !seen && global)\n-\t\tgit_config_from_file(show_config, global);\n-\tif (!do_all && !seen && system_wide)\n-\t\tgit_config_from_file(show_config, system_wide);\n+\tif (dest)\n+\t\tgit_config_from_remote(show_config, dest);\n+\telse {\n+\t\tif (do_all && system_wide)\n+\t\t\tgit_config_from_file(show_config, system_wide);\n+\t\tif (do_all && global)\n+\t\t\tgit_config_from_file(show_config, global);\n+\t\tgit_config_from_file(show_config, local);\n+\t\tif (!do_all && !seen && global)\n+\t\t\tgit_config_from_file(show_config, global);\n+\t\tif (!do_all && !seen && system_wide)\n+\t\t\tgit_config_from_file(show_config, system_wide);\n+\t}\n \n \tfree(key);\n \tif (regexp) {\n@@ -155,8 +161,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\telse if (!strcmp(argv[1], \"--system\"))\n \t\t\tsetenv(\"GIT_CONFIG\", ETC_GITCONFIG, 1);\n+\t\telse if (!prefixcmp(argv[1], \"--remote=\"))\n+\t\t\tdest = xstrdup(argv[1]+9);\n \t\telse if (!strcmp(argv[1], \"--rename-section\")) {\n \t\t\tint ret;\n+\t\t\tif (dest) {\n+\t\t\t\tfprintf(stderr, \"Cannot rename on remote\\n\");\n+\t\t\t\treturn 1;\n+\t\t\t}\n \t\t\tif (argc != 4)\n \t\t\t\tusage(git_config_set_usage);\n \t\t\tret = git_config_rename_section(argv[2], argv[3]);\n@@ -170,6 +182,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\telse if (!strcmp(argv[1], \"--remove-section\")) {\n \t\t\tint ret;\n+\t\t\tif (dest) {\n+\t\t\t\tfprintf(stderr, \"Cannot remove on remote\\n\");\n+\t\t\t\treturn 1;\n+\t\t\t}\n \t\t\tif (argc != 3)\n \t\t\t\tusage(git_config_set_usage);\n \t\t\tret = git_config_rename_section(argv[2], NULL);\n@@ -191,6 +207,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \tcase 2:\n \t\treturn get_value(argv[1], NULL);\n \tcase 3:\n+\t\tif (dest && prefixcmp(argv[1], \"--get\")) {\n+\t\t\tfprintf(stderr, \"Cannot (un)set on remote\\n\");\n+\t\t\treturn 1;\n+\t\t}\n \t\tif (!strcmp(argv[1], \"--unset\"))\n \t\t\treturn git_config_set(argv[2], NULL);\n \t\telse if (!strcmp(argv[1], \"--unset-all\"))\n@@ -209,6 +229,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \n \t\t\treturn git_config_set(argv[1], argv[2]);\n \tcase 4:\n+\t\tif (dest && prefixcmp(argv[1], \"--get\")) {\n+\t\t\tfprintf(stderr, \"Cannot (un)set on remote\\n\");\n+\t\t\treturn 1;\n+\t\t}\n \t\tif (!strcmp(argv[1], \"--unset\"))\n \t\t\treturn git_config_set_multivar(argv[2], NULL, argv[3], 0);\n \t\telse if (!strcmp(argv[1], \"--unset-all\"))\ndiff --git a/cache.h b/cache.h\nindex 8e76152..e8c7791 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -499,6 +499,7 @@ extern int update_server_info(int);\n typedef int (*config_fn_t)(const char *, const char *);\n extern int git_default_config(const char *, const char *);\n extern int git_config_from_file(config_fn_t fn, const char *);\n+extern int git_config_from_remote(config_fn_t fn, char *dest);\n extern int git_config(config_fn_t fn);\n extern int git_config_int(const char *, const char *);\n extern int git_config_bool(const char *, const char *);\ndiff --git a/config.c b/config.c\nindex 70d1055..0da74e0 100644\n--- a/config.c\n+++ b/config.c\n@@ -6,9 +6,12 @@\n  *\n  */\n #include \"cache.h\"\n+#include \"pkt-line.h\"\n \n #define MAXNAME (256)\n \n+static const char *dumpconfig = \"git-dump-config\";\n+\n static FILE *config_file;\n static const char *config_file_name;\n static int config_linenr;\n@@ -392,6 +395,29 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n \treturn ret;\n }\n \n+int git_config_from_remote(config_fn_t fn, char *dest)\n+{\n+\tint ret;\n+\tint fd[2];\n+\tpid_t pid;\n+\tstatic char var[MAXNAME];\n+\tstatic char value[1024];\n+\n+\tpid = git_connect(fd, dest, dumpconfig);\n+\tif (pid < 0)\n+\t\treturn 1;\n+\tret = 0;\n+\twhile (packet_read_line(fd[0], var, sizeof(var))) {\n+\t\tif (!packet_read_line(fd[0], value, sizeof(value)))\n+\t\t\tdie(\"Missing value\");\n+\t\tfn(var, value);\n+\t}\n+\tclose(fd[0]);\n+\tclose(fd[1]);\n+\tret |= finish_connect(pid);\n+\treturn !!ret;\n+}\n+\n int git_config(config_fn_t fn)\n {\n \tint ret = 0;\n-- \n1.5.2.rc1.25.g889f-dirty\n"},{"id":"41043","messageId":"11782757672551-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":"11782757671754-git-send-email-skimo@liacs.nl","subject":"[PATCH] http.h: make fill_active_slots a function pointer","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:25Z","receivedAt":"2007-05-04T10:49:25Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nThis allows us to use the methods provided by http.c\nfrom within libgit, in particular config.c.\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n---\n http-fetch.c |    5 ++++-\n http-push.c  |    5 ++++-\n http.h       |    2 +-\n 3 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex 09baedc..53fb2a9 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -317,7 +317,7 @@ static void release_object_request(struct object_request *obj_req)\n }\n \n #ifdef USE_CURL_MULTI\n-void fill_active_slots(void)\n+static void fetch_fill_active_slots(void)\n {\n \tstruct object_request *obj_req = object_queue_head;\n \tstruct active_request_slot *slot = active_queue_head;\n@@ -1031,6 +1031,9 @@ int main(int argc, const char **argv)\n \t}\n \turl = argv[arg];\n \n+#ifdef USE_CURL_MULTI\n+\tfill_active_slots = fetch_fill_active_slots;\n+#endif\n \thttp_init();\n \n \tno_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\ndiff --git a/http-push.c b/http-push.c\nindex e3f7675..d4c850b 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -794,7 +794,7 @@ static void finish_request(struct transfer_request *request)\n }\n \n #ifdef USE_CURL_MULTI\n-void fill_active_slots(void)\n+static void push_fill_active_slots(void)\n {\n \tstruct transfer_request *request = request_queue_head;\n \tstruct transfer_request *next;\n@@ -2355,6 +2355,9 @@ int main(int argc, char **argv)\n \n \tmemset(remote_dir_exists, -1, 256);\n \n+#ifdef USE_CURL_MULTI\n+\tfill_active_slots = push_fill_active_slots;\n+#endif\n \thttp_init();\n \n \tno_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\ndiff --git a/http.h b/http.h\nindex 69b6b66..7a41cde 100644\n--- a/http.h\n+++ b/http.h\n@@ -69,7 +69,7 @@ extern void finish_all_active_slots(void);\n extern void release_active_slot(struct active_request_slot *slot);\n \n #ifdef USE_CURL_MULTI\n-extern void fill_active_slots(void);\n+extern void (*fill_active_slots)(void);\n extern void step_active_slots(void);\n #endif\n \n-- \n1.5.2.rc1.25.g889f-dirty\n"},{"id":"41046","messageId":"11782757671933-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":"11782757671754-git-send-email-skimo@liacs.nl","subject":"[PATCH] git-config: read remote config files over HTTP","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:26Z","receivedAt":"2007-05-04T10:49:26Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n---\n Makefile           |    6 +++++-\n config.c           |   14 ++++++++++++++\n http.c             |   10 ++++++++--\n http_config.h      |    1 +\n http_config_curl.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++\n http_config_none.c |    6 ++++++\n 6 files changed, 83 insertions(+), 3 deletions(-)\n create mode 100644 http_config.h\n create mode 100644 http_config_curl.c\n create mode 100644 http_config_none.c\n\ndiff --git a/Makefile b/Makefile\nindex 0185386..b782111 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -311,7 +311,7 @@ LIB_OBJS = \\\n \twrite_or_die.o trace.o list-objects.o grep.o match-trees.o \\\n \talloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \\\n \tcolor.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \\\n-\tconvert.o attr.o decorate.o progress.o mailmap.o\n+\tconvert.o attr.o decorate.o progress.o mailmap.o $(HTTP_CONFIG_OBJ)\n \n BUILTIN_OBJS = \\\n \tbuiltin-add.o \\\n@@ -518,6 +518,10 @@ ifndef NO_CURL\n \tifndef NO_EXPAT\n \t\tEXPAT_LIBEXPAT = -lexpat\n \tendif\n+\tHTTP_CONFIG_OBJ = http_config_curl.o http.o\n+\tEXTLIBS += $(CURL_LIBCURL)\n+else\n+\tHTTP_CONFIG_OBJ = http_config_none.o\n endif\n \n ifndef NO_OPENSSL\ndiff --git a/config.c b/config.c\nindex 0da74e0..36e3b97 100644\n--- a/config.c\n+++ b/config.c\n@@ -7,6 +7,7 @@\n  */\n #include \"cache.h\"\n #include \"pkt-line.h\"\n+#include \"http_config.h\"\n \n #define MAXNAME (256)\n \n@@ -395,6 +396,16 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n \treturn ret;\n }\n \n+static int config_from_http(config_fn_t fn, char *dest)\n+{\n+\tstatic char *config_temp = \"config.temp\";\n+\tif (git_http_fetch_config(dest, config_temp))\n+\t\treturn 1;\n+\tgit_config_from_file(fn, config_temp);\n+\tunlink(config_temp);\n+\treturn 0;\n+}\n+\n int git_config_from_remote(config_fn_t fn, char *dest)\n {\n \tint ret;\n@@ -403,6 +414,9 @@ int git_config_from_remote(config_fn_t fn, char *dest)\n \tstatic char var[MAXNAME];\n \tstatic char value[1024];\n \n+\tif (!prefixcmp(dest, \"http://\"))\n+\t\treturn config_from_http(fn, dest);\n+\n \tpid = git_connect(fd, dest, dumpconfig);\n \tif (pid < 0)\n \t\treturn 1;\ndiff --git a/http.c b/http.c\nindex ae27e0c..3e1ccce 100644\n--- a/http.c\n+++ b/http.c\n@@ -25,6 +25,10 @@ long curl_low_speed_limit = -1;\n long curl_low_speed_time = -1;\n int curl_ftp_no_epsv = 0;\n \n+#ifdef USE_CURL_MULTI\n+void (*fill_active_slots)(void) = NULL;\n+#endif\n+\n struct curl_slist *pragma_header;\n \n struct active_request_slot *active_queue_head = NULL;\n@@ -394,7 +398,8 @@ void step_active_slots(void)\n \t} while (curlm_result == CURLM_CALL_MULTI_PERFORM);\n \tif (num_transfers < active_requests) {\n \t\tprocess_curl_messages();\n-\t\tfill_active_slots();\n+\t\tif (fill_active_slots)\n+\t\t\tfill_active_slots();\n \t}\n }\n #endif\n@@ -459,7 +464,8 @@ void release_active_slot(struct active_request_slot *slot)\n \t\tslot->curl = NULL;\n \t}\n #ifdef USE_CURL_MULTI\n-\tfill_active_slots();\n+\tif (fill_active_slots)\n+\t\tfill_active_slots();\n #endif\n }\n \ndiff --git a/http_config.h b/http_config.h\nnew file mode 100644\nindex 0000000..0fddf98\n--- /dev/null\n+++ b/http_config.h\n@@ -0,0 +1 @@\n+int git_http_fetch_config(const char *repo, const char *config_file);\ndiff --git a/http_config_curl.c b/http_config_curl.c\nnew file mode 100644\nindex 0000000..3047ea2\n--- /dev/null\n+++ b/http_config_curl.c\n@@ -0,0 +1,49 @@\n+#include \"http_config.h\"\n+#include \"http.h\"\n+\n+int git_http_fetch_config(const char *repo, const char *config)\n+{\n+\tchar url[PATH_MAX];\n+\tint len = strlen(repo);\n+\n+\tFILE *configfile;\n+\tstruct active_request_slot *slot;\n+\tstruct slot_results results;\n+\n+\tstrcpy(url, repo);\n+\twhile (len > 0 && url[len-1] == '/')\n+\t\t--len;\n+\tsnprintf(url+len, sizeof(url)-len, \"/config\");\n+\n+\tconfigfile = fopen(config, \"w\");\n+\tif (!configfile)\n+\t\treturn error(\"Unable to open local file %s for config\",\n+\t\t\t     config);\n+\n+\thttp_init();\n+\n+\tslot = get_active_slot();\n+\tslot->results = &results;\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, configfile);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n+\tslot->local = configfile;\n+\n+\tif (start_active_slot(slot)) {\n+\t\trun_active_slot(slot);\n+\t\tif (results.curl_result != CURLE_OK) {\n+\t\t\tfclose(configfile);\n+\t\t\treturn error(\"Unable to get config %s\\n%s\", url,\n+\t\t\t\t     curl_errorstr);\n+\t\t}\n+\t} else {\n+\t\tfclose(configfile);\n+\t\treturn error(\"Unable to start request\");\n+\t}\n+\n+\thttp_cleanup();\n+\n+\tfclose(configfile);\n+\n+\treturn 0;\n+}\ndiff --git a/http_config_none.c b/http_config_none.c\nnew file mode 100644\nindex 0000000..303160b\n--- /dev/null\n+++ b/http_config_none.c\n@@ -0,0 +1,6 @@\n+#include \"http_config.h\"\n+\n+int git_http_fetch_config(const char *repo, const char *config_file)\n+{\n+\treturn error(\"Reading http config files not supported\");\n+}\n-- \n1.5.2.rc1.25.g889f-dirty\n"},{"id":"41045","messageId":"11782757681900-git-send-email-skimo@liacs.nl","threadId":"7972","inReplyTo":"11782757671754-git-send-email-skimo@liacs.nl","subject":"[PATCH] git-clone: add --submodules for cloning submodules","fromName":"Sven Verdoolaege","fromEmail":"skimo@liacs.nl","sentAt":"2007-05-04T10:49:27Z","receivedAt":"2007-05-04T10:49:27Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"From: Sven Verdoolaege <skimo@kotnet.org>\n\nWhen the --submodules option is specified, git-clone will search\nfor submodule.<submodule>.url options in the remote configuration\nand clone each submodule using the first url that it can use from\nthe local site.\n\nThe submodules are currently not checked out.\n\nSigned-off-by: Sven Verdoolaege <skimo@kotnet.org>\n---\n Documentation/config.txt    |    3 ++\n Documentation/git-clone.txt |    6 +++-\n git-clone.sh                |   68 ++++++++++++++++++++++++++++++++++++++++++-\n 3 files changed, 75 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 24f9655..92747d8 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -597,6 +597,9 @@ showbranch.default::\n \tThe default set of branches for gitlink:git-show-branch[1].\n \tSee gitlink:git-show-branch[1].\n \n+submodule.<submodule>.url\n+\tThe URL of a submodule.  See gitlink:git-clone[1].\n+\n tar.umask::\n \tBy default, gitlink:git-tar-tree[1] sets file and directories modes\n \tto 0666 or 0777. While this is both useful and acceptable for projects\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 6d32c49..b112a6a 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -11,7 +11,7 @@ SYNOPSIS\n [verse]\n 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]\n \t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n-\t  [--depth <depth>] <repository> [<directory>]\n+\t  [--depth <depth>] [--submodules] <repository> [<directory>]\n \n DESCRIPTION\n -----------\n@@ -105,6 +105,10 @@ OPTIONS\n \twith a long history, and would want to send in a fixes\n \tas patches.\n \n+--submodules::\n+\tClone submodules specified in (remote) configuration parameters\n+\tsubmodule.<submodule>.url.\n+\n <repository>::\n \tThe (possibly remote) repository to clone from.  It can\n \tbe any URL git-fetch supports.\ndiff --git a/git-clone.sh b/git-clone.sh\nindex cad5c0c..3a9b09c 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -14,7 +14,7 @@ die() {\n }\n \n usage() {\n-\tdie \"Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>]\"\n+\tdie \"Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] [--submodules] <repo> [<dir>]\"\n }\n \n get_repo_base() {\n@@ -67,6 +67,60 @@ Perhaps git-update-server-info needs to be run there?\"\n \trm -f \"$GIT_DIR/REMOTE_HEAD\"\n }\n \n+local_URL() {\n+\t# tranforms a \"URL\" on the remote to a URL that works on the local machine\n+\t# $1 - remote, $2 - URL on remote\n+\tcase \"$1\" in\n+\thttps://*|http://*|ftp://*)\n+\t\tcase \"$2\" in\n+\t\thttps://*|http://*|ftp://*)\n+\t\t\techo $2\n+\t\tesac\n+\t\t;;\n+\tssh://*)\n+\t\tcase \"$2\" in\n+\t\thttps://*|http://*|ftp://*)\n+\t\t\techo $2\n+\t\t\t;;\n+\t\t/*)\n+\t\t\techo $(echo $1 | sed -e 's/\\(ssh:\\/\\/[^\\/]*\\)\\/.*/\\1/')$2\n+\t\tesac\n+\t\t;;\n+\t/*)\n+\t\techo $2\n+\t\t;;\n+\t*)\n+\t\tcase \"$2\" in\n+\t\thttps://*|http://*|ftp://*)\n+\t\t\techo $2\n+\t\tesac\n+\tesac\n+}\n+\n+clone_submodules () {\n+\t# $1 - remote\n+\tprevious=\n+\tgit-config --remote=$1 --get-regexp 'submodule\\..*\\.url' | \\\n+\tsed -e 's/^submodule\\.//;s/\\.url / /' |\n+\twhile read submodule URL\n+\tdo\n+\t\techo \"$submodule $URL\"\n+\t\tif test \"$submodule\" = \"$previous\"\n+\t\tthen\n+\t\t\tcontinue;\n+\t\tfi\n+\t\tURL=$(local_URL \"$1\" \"$URL\")\n+\t\techo \"$submodule $URL\"\n+\t\tif test -z \"$URL\"\n+\t\tthen\n+\t\t\tcontinue;\n+\t\tfi\n+\t\tgit-clone -n \"$URL\" \"$submodule\"\n+\t\tgit-config \"submodule.$submodule.url\" \"$URL\"\n+\t\tprevious=\"$submodule\"\n+\tdone\n+}\n+\n quiet=\n local=no\n use_local=no\n@@ -81,6 +135,7 @@ origin_override=\n use_separate_remote=t\n depth=\n no_progress=\n+submodules=\n test -t 1 || no_progress=--no-progress\n while\n \tcase \"$#,$1\" in\n@@ -131,6 +186,8 @@ while\n \t*,--depth)\n \t\tshift\n \t\tdepth=\"--depth=$1\";;\n+\t*,--su|*,--sub|*,--subm|*,--submo|*,--submod|*,--submodu|*,--submodul|\\\n+\t*,--submodule|*,--submodules) submodules=yes ;;\n \t*,-*) usage ;;\n \t*) break ;;\n \tesac\n@@ -149,6 +206,10 @@ then\n \tthen\n \t\tdie '--bare and --origin $origin options are incompatible.'\n \tfi\n+\tif test yes = \"$submodules\"\n+\tthen\n+\t\tdie '--bare and --submodules origin options are incompatible.'\n+\tfi\n \tno_checkout=yes\n \tuse_separate_remote=\n fi\n@@ -394,6 +455,11 @@ then\n \t\tgit-config branch.\"$head_points_at\".merge \"refs/heads/$head_points_at\"\n \tesac\n \n+\tif test yes = \"$submodules\"\n+\tthen\n+\t\tclone_submodules \"$repo\"\n+\tfi\n+\n \tcase \"$no_checkout\" in\n \t'')\n \t\ttest \"z$quiet\" = z -a \"z$no_progress\" = z && v=-v || v=\n-- \n1.5.2.rc1.25.g889f-dirty\n"},{"id":"41181","messageId":"7virb6fnkv.fsf@assigned-by-dhcp.cox.net","threadId":"7972","inReplyTo":"11782757671933-git-send-email-skimo@liacs.nl","subject":"Re: [PATCH] git-config: read remote config files over HTTP","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-06T06:55:28Z","receivedAt":"2007-05-06T06:55:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sven Verdoolaege <skimo@liacs.nl> writes:\n\n> diff --git a/Makefile b/Makefile\n> index 0185386..b782111 100644\n> --- a/Makefile\n> +++ b/Makefile\n\nVery nicely done. \n\n> diff --git a/config.c b/config.c\n> index 0da74e0..36e3b97 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -7,6 +7,7 @@\n>   */\n>  #include \"cache.h\"\n>  #include \"pkt-line.h\"\n> +#include \"http_config.h\"\n>  \n>  #define MAXNAME (256)\n>  \n> @@ -395,6 +396,16 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n>  \treturn ret;\n>  }\n>  \n> +static int config_from_http(config_fn_t fn, char *dest)\n> +{\n> +\tstatic char *config_temp = \"config.temp\";\n> +\tif (git_http_fetch_config(dest, config_temp))\n> +\t\treturn 1;\n> +\tgit_config_from_file(fn, config_temp);\n> +\tunlink(config_temp);\n> +\treturn 0;\n> +}\n\nNot mkstemp()?\n\n> @@ -403,6 +414,9 @@ int git_config_from_remote(config_fn_t fn, char *dest)\n>  \tstatic char var[MAXNAME];\n>  \tstatic char value[1024];\n>  \n> +\tif (!prefixcmp(dest, \"http://\"))\n> +\t\treturn config_from_http(fn, dest);\n> +\n\nShouldn't this also work for other protocols we handle via curl?\n\n> diff --git a/http.c b/http.c\n> index ae27e0c..3e1ccce 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -25,6 +25,10 @@ long curl_low_speed_limit = -1;\n>  long curl_low_speed_time = -1;\n>  int curl_ftp_no_epsv = 0;\n>  \n> +#ifdef USE_CURL_MULTI\n> +void (*fill_active_slots)(void) = NULL;\n> +#endif\n> +\n\nI wonder if we could lose USE_CURL_MULTI around this one,...\n\n>  struct curl_slist *pragma_header;\n>  \n>  struct active_request_slot *active_queue_head = NULL;\n> @@ -394,7 +398,8 @@ void step_active_slots(void)\n>  \t} while (curlm_result == CURLM_CALL_MULTI_PERFORM);\n>  \tif (num_transfers < active_requests) {\n>  \t\tprocess_curl_messages();\n> -\t\tfill_active_slots();\n> +\t\tif (fill_active_slots)\n> +\t\t\tfill_active_slots();\n>  \t}\n>  }\n>  #endif\n> @@ -459,7 +464,8 @@ void release_active_slot(struct active_request_slot *slot)\n>  \t\tslot->curl = NULL;\n>  \t}\n>  #ifdef USE_CURL_MULTI\n> -\tfill_active_slots();\n> +\tif (fill_active_slots)\n> +\t\tfill_active_slots();\n>  #endif\n>  }\n\n... and especially this one.\n\nThe fill_active_slots variable may happen to stay at NULL under\n!USE_CURL_MULTI, because the only code that sets the variable\nwould be in #ifdef USE_CURL_MULTI.\n"},{"id":"41210","messageId":"20070506135306.GB942MdfPADPa@greensroom.kotnet.org","threadId":"7972","inReplyTo":"7virb6fnkv.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-config: read remote config files over HTTP","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-05-06T13:53:06Z","receivedAt":"2007-05-06T13:53:06Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Sat, May 05, 2007 at 11:55:28PM -0700, Junio C Hamano wrote:\n> Sven Verdoolaege <skimo@liacs.nl> writes:\n> > +static int config_from_http(config_fn_t fn, char *dest)\n> > +{\n> > +\tstatic char *config_temp = \"config.temp\";\n> > +\tif (git_http_fetch_config(dest, config_temp))\n> > +\t\treturn 1;\n> > +\tgit_config_from_file(fn, config_temp);\n> > +\tunlink(config_temp);\n> > +\treturn 0;\n> > +}\n> \n> Not mkstemp()?\n\nI more or less copy-pasted the way \"index\" is handled now.\nI'll use mkstemp in the next round.\n\n> > +\tif (!prefixcmp(dest, \"http://\"))\n> > +\t\treturn config_from_http(fn, dest);\n> > +\n> \n> Shouldn't this also work for other protocols we handle via curl?\n\nI don't think I copied the required setup for https, but ftp should work.\n\n> > +#ifdef USE_CURL_MULTI\n> > +void (*fill_active_slots)(void) = NULL;\n> > +#endif\n> > +\n> \n> I wonder if we could lose USE_CURL_MULTI around this one,...\n\nI wondered about that too, but I wanted to make my changes as minimal\nas possible.  I'll drop the #ifdef in the next round.\n\nskimo\n"}]}