Initial support for cloning submodules
Subsystems (2)
From: Sven Verdoolaege <[email protected]>
This patch series implements a mechanism for cloning submodules. Each submodule is specified by a 'submodule.<submodule>.url' configuration option, e.g.,
bash-3.00$ ./git-config --remote=http://www.liacs.nl/~sverdool/isa.git --get-regexp 'submodule\..*\.url' submodule.cloog.url /home/sverdool/public_html/cloog.git
submodule.cloog.url http://www.liacs.nl/~sverdool/cloog.git
git-clone will use the first url that works.
E.g., a
git clone --submodules ssh://liacs/~/public_html/isa.git
(which only works for me), will use the first url, while a
git clone --submodules http://www.liacs.nl/~sverdool/isa.git
will use the second.
The submodules are currently not checked out.
skimo
PATCH 1/1 git-config: read remote config files over HTTP
From: Sven Verdoolaege <[email protected]>
--- Makefile | 6 +++++- config.c | 14 ++++++++++++++ http.c | 10 ++++++++-- http_config.h | 1 + http_config_curl.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ http_config_none.c | 6 ++++++ 6 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 http_config.h create mode 100644 http_config_curl.c create mode 100644 http_config_none.c
Makefile +5 -1
@@ -311,7 +311,7 @@ LIB_OBJS = \ write_or_die.o trace.o list-objects.o grep.o match-trees.o \ alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \ color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \ - convert.o attr.o decorate.o progress.o mailmap.o + convert.o attr.o decorate.o progress.o mailmap.o $(HTTP_CONFIG_OBJ) BUILTIN_OBJS = \ builtin-add.o \
@@ -518,6 +518,10 @@ ifndef NO_CURL ifndef NO_EXPAT EXPAT_LIBEXPAT = -lexpat endif + HTTP_CONFIG_OBJ = http_config_curl.o http.o + EXTLIBS += $(CURL_LIBCURL) +else + HTTP_CONFIG_OBJ = http_config_none.o endif ifndef NO_OPENSSL
config.c +14 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" #include "pkt-line.h" +#include "http_config.h" #define MAXNAME (256)
@@ -395,6 +396,16 @@ int git_config_from_file(config_fn_t fn, const char *filename)return ret; } +static int config_from_http (config_fn_t fn,char *dest) +{ +static char *config_temp ="config.temp" ; +if (git_http_fetch_config (dest, config_temp)) +return 1 ; +git_config_from_file (fn, config_temp); +unlink (config_temp); +return 0 ; +} +int git_config_from_remote (config_fn_t fn,char *dest) {int ret;
@@ -403,6 +414,9 @@ int git_config_from_remote(config_fn_t fn, char *dest)static char var[MAXNAME ];static char value[1024 ]; +if (!prefixcmp (dest,"http://" )) +return config_from_http (fn, dest); + pid =git_connect (fd, dest, dumpconfig);if (pid <0 )return 1 ;
http.c +8 -2
@@ -25,6 +25,10 @@ long curl_low_speed_limit = -1;long curl_low_speed_time =-1 ;int curl_ftp_no_epsv =0 ; +#ifdef USE_CURL_MULTI +void (*fill_active_slots)(void ) =NULL ; +#endif +struct curl_slist *pragma_header;struct active_request_slot *active_queue_head =NULL ;
@@ -394,7 +398,8 @@ void step_active_slots(void) } while (curlm_result == CURLM_CALL_MULTI_PERFORM);if (num_transfers < active_requests) {process_curl_messages (); -fill_active_slots (); +if (fill_active_slots) +fill_active_slots (); } }#endif
@@ -459,7 +464,8 @@ void release_active_slot(struct active_request_slot *slot) slot->curl =NULL ; }#ifdef USE_CURL_MULTI -fill_active_slots (); +if (fill_active_slots) +fill_active_slots ();#endif }
http_config.h new file +1 -0
@@ -0,0 +1 @@ +int git_http_fetch_config (const char *repo,const char *config_file);
http_config_curl.c new file +49 -0
49 lines not on this page · raw message
http_config_none.c new file +6 -0
@@ -0,0 +1,6 @@ +#include "http_config.h" + +int git_http_fetch_config (const char *repo,const char *config_file) +{ +return error ("Reading http config files not supported" ); +}
Signature · 1 line
1.5.2.rc1.25.g889f-dirty
Re: [PATCH] git-config: read remote config files over HTTP
Makefile
Quoted 4 lines · Sven Verdoolaege
Makefile +0
-0
Very nicely done.
Quoted 15 lines
config.c +1
-0@@ -7,6 +7,7 @@*/ #include "cache.h" #include "pkt-line.h" +#include "http_config.h" #define MAXNAME (256)@@ -395,6 +396,16 @@ int git_config_from_file(config_fn_t fn, const char *filename)return ret; }
config.c int git_config_from_file(config_fn_t fn, const char *filename) · line 407
Quoted 10 lines
config.c +9
-0+static int config_from_http (config_fn_t fn,char *dest) +{ +static char *config_temp ="config.temp" ; +if (git_http_fetch_config (dest, config_temp)) +return 1 ; +git_config_from_file (fn, config_temp); +unlink (config_temp); +return 0 ; +}
Not mkstemp()?
config.c int git_config_from_remote(config_fn_t fn, char *dest) · line 419
Quoted 7 lines
config.c +3
-0@@ -403,6 +414,9 @@ int git_config_from_remote(config_fn_t fn, char *dest)static char var[MAXNAME ];static char value[1024 ]; +if (!prefixcmp (dest,"http://" )) +return config_from_http (fn, dest); +
Shouldn't this also work for other protocols we handle via curl?
http.c long curl_low_speed_limit = -1; · line 31
Quoted 12 lines
http.c +4
-0@@ -25,6 +25,10 @@ long curl_low_speed_limit = -1;long curl_low_speed_time =-1 ;int curl_ftp_no_epsv =0 ; +#ifdef USE_CURL_MULTI +void (*fill_active_slots)(void ) =NULL ; +#endif +
I wonder if we could lose USE_CURL_MULTI around this one,...
Quoted 14 lines
http.c +2
-1struct curl_slist *pragma_header;struct active_request_slot *active_queue_head =NULL ;@@ -394,7 +398,8 @@ void step_active_slots(void) } while (curlm_result == CURLM_CALL_MULTI_PERFORM);if (num_transfers < active_requests) {process_curl_messages (); -fill_active_slots (); +if (fill_active_slots) +fill_active_slots (); } }#endif
http.c void release_active_slot(struct active_request_slot *slot) · line 470
Quoted 8 lines
http.c +2
-1@@ -459,7 +464,8 @@ void release_active_slot(struct active_request_slot *slot) slot->curl =NULL ; }#ifdef USE_CURL_MULTI -fill_active_slots (); +if (fill_active_slots) +fill_active_slots ();#endif }
... and especially this one.
The fill_active_slots variable may happen to stay at NULL under !USE_CURL_MULTI, because the only code that sets the variable would be in #ifdef USE_CURL_MULTI.
Re: [PATCH] git-config: read remote config files over HTTP
Quoted 12 lines · Junio C Hamano
config.c int git_config_from_file(config_fn_t fn, const char *filename) · line 407
Quoted 9 lines · Sven Verdoolaege
config.c +9
-0+static int config_from_http (config_fn_t fn,char *dest) +{ +static char *config_temp ="config.temp" ; +if (git_http_fetch_config (dest, config_temp)) +return 1 ; +git_config_from_file (fn, config_temp); +unlink (config_temp); +return 0 ; +}Not
mkstemp()?
I more or less copy-pasted the way "index" is handled now. I'll use mkstemp in the next round.
Quoted 5 lines
config.c int git_config_from_remote(config_fn_t fn, char *dest) · line 419
Quoted 3 lines
config.c +3
-0+if (!prefixcmp (dest,"http://" )) +return config_from_http (fn, dest); +Shouldn't this also work for other protocols we handle via curl?
I don't think I copied the required setup for https, but ftp should work.
Quoted 6 lines
http.c long curl_low_speed_limit = -1; · line 31
Quoted 4 lines
http.c +4
-0+#ifdef USE_CURL_MULTI +void (*fill_active_slots)(void ) =NULL ; +#endif +I wonder if we could lose
USE_CURL_MULTIaround this one,...
I wondered about that too, but I wanted to make my changes as minimal as possible. I'll drop the #ifdef in the next round.
skimo
PATCH 1/1 Add dump-config
In reply to Sven VerdoolaegeFrom: Sven Verdoolaege <[email protected]>
This command dumps the config of a repository and will be used to read config options from a remote site.
--- .gitignore | 1 + Documentation/cmd-list.perl | 1 + Documentation/git-dump-config.txt | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 1 + daemon.c | 7 +++++++ dump-config.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-dump-config.txt create mode 100644 dump-config.c
.gitignore +1 -0
@@ -38,6 +38,7 @@ git-diff-files git-diff-index git-diff-tree git-describe +git-dump-config git-fast-import git-fetch git-fetch--tool
Documentation/cmd-list.perl +1 -0
@@ -103,6 +103,7 @@ git-diff-files plumbinginterrogators git-diff-index plumbinginterrogators git-diff mainporcelain git-diff-tree plumbinginterrogators +git-dump-config synchelpers git-fast-import ancillarymanipulators git-fetch mainporcelain git-fetch-pack synchingrepositories
Documentation/git-dump-config.txt new file +37 -0
@@ -0,0 +1,37 @@ +git-dump-config(1) +==================== + +NAME +---- +git-dump-config - Dump config options + + +SYNOPSIS +-------- +'git-dump-config' <directory> + +DESCRIPTION +----------- +Invoked by 'git-config --remote' and dumps the config file to the +other end over the git protocol. + +This command is usually not invoked directly by the end user. The UI +for the protocol is on the 'git-config' side, where it is used to get +options from a remote repository. + +OPTIONS +------- +<directory>:: + The repository to get the config options from. + +Author +------ +Written by Sven Verdoolaege. + +Documentation +-------------- +Documentation by Sven Verdoolaege. + +GIT +--- +Part of the gitlink:git[7] suite
Makefile +1 -0
@@ -232,6 +232,7 @@ PROGRAMS = \ git-fast-import$X \ git-merge-base$X \ git-daemon$X \ + git-dump-config$X \ git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \ git-peek-remote$X git-receive-pack$X \ git-send-pack$X git-shell$X \
daemon.c +7 -0
@@ -378,10 +378,17 @@ static int receive_pack(void)return -1 ; } +static int dump_config (void ) +{ +execl_git_cmd ("dump-config" ,"." ,NULL ); +return -1 ; +} +static struct daemon_service daemon_service[] = { {"upload-archive" ,"uploadarch" , upload_archive,0 ,1 }, {"upload-pack" ,"uploadpack" , upload_pack,1 ,1 }, {"receive-pack" ,"receivepack" , receive_pack,0 ,1 }, + {"dump-config" ,"dumpconfig" , dump_config,0 ,1 }, };static void enable_service (const char *name,int ena) {
dump-config.c new file +29 -0
@@ -0,0 +1,29 @@ +#include "git-compat-util.h" +#include "cache.h" +#include "pkt-line.h" + +static const char dump_config_usage[] ="git-dump-config <dir>" ; + +static int dump_config (const char *var,const char *value) +{ +packet_write (1 ,"%s" , var); +packet_write (1 ,"%s" , value); +return 0 ; +} + +int main (int argc,char **argv) +{ +char *dir; + +if (argc !=2 ) +usage (dump_config_usage); + + dir = argv[1 ]; +if (!enter_repo (dir,0 )) +die ("'%s': unable to chdir or not a git archive" , dir); + +git_config (dump_config); +packet_flush (1 ); + +return 0 ; +}
Signature · 1 line
1.5.2.rc1.25.g889f-dirty
PATCH 1/1 http.h: make fill_active_slots a function pointer
In reply to Sven VerdoolaegeFrom: Sven Verdoolaege <[email protected]>
This allows us to use the methods provided by http.c from within libgit, in particular config.c.
--- http-fetch.c | 5 ++++- http-push.c | 5 ++++- http.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
http-fetch.c +4 -1
@@ -317,7 +317,7 @@ static void release_object_request(struct object_request *obj_req) }#ifdef USE_CURL_MULTI -void fill_active_slots (void ) +static void fetch_fill_active_slots (void ) {struct object_request *obj_req = object_queue_head;struct active_request_slot *slot = active_queue_head;
@@ -1031,6 +1031,9 @@ int main(int argc, const char **argv) } url = argv[arg]; +#ifdef USE_CURL_MULTI + fill_active_slots = fetch_fill_active_slots; +#endif http_init (); no_pragma_header =curl_slist_append (no_pragma_header,"Pragma:" );
http-push.c +4 -1
@@ -794,7 +794,7 @@ static void finish_request(struct transfer_request *request) }#ifdef USE_CURL_MULTI -void fill_active_slots (void ) +static void push_fill_active_slots (void ) {struct transfer_request *request = request_queue_head;struct transfer_request *next;
@@ -2355,6 +2355,9 @@ int main(int argc, char **argv)memset (remote_dir_exists,-1 ,256 ); +#ifdef USE_CURL_MULTI + fill_active_slots = push_fill_active_slots; +#endif http_init (); no_pragma_header =curl_slist_append (no_pragma_header,"Pragma:" );
http.h +1 -1
@@ -69,7 +69,7 @@ extern void finish_all_active_slots(void);extern void release_active_slot (struct active_request_slot *slot);#ifdef USE_CURL_MULTI -extern void fill_active_slots (void ); +extern void (*fill_active_slots)(void );extern void step_active_slots (void );#endif
Signature · 1 line
1.5.2.rc1.25.g889f-dirty
PATCH 1/1 git-config: add --remote option for reading config from remote repo
In reply to Sven VerdoolaegeFrom: Sven Verdoolaege <[email protected]>
--- Documentation/git-config.txt | 33 +++++++++++++++++++++--------- builtin-config.c | 44 ++++++++++++++++++++++++++++++++--------- cache.h | 1 + config.c | 26 ++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 20 deletions(-)
Documentation/git-config.txt +23 -10
@@ -9,16 +9,25 @@ git-config - Get and set repository or global options SYNOPSIS -------- [verse] -'git-config' [--system | --global] [type] name [value [value_regex]] -'git-config' [--system | --global] [type] --add name value -'git-config' [--system | --global] [type] --replace-all name [value [value_regex]] -'git-config' [--system | --global] [type] --get name [value_regex] -'git-config' [--system | --global] [type] --get-all name [value_regex] -'git-config' [--system | --global] [type] --unset name [value_regex] -'git-config' [--system | --global] [type] --unset-all name [value_regex] -'git-config' [--system | --global] [type] --rename-section old_name new_name -'git-config' [--system | --global] [type] --remove-section name -'git-config' [--system | --global] -l | --list +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] name [value [value_regex]] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --add name value +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --replace-all name [value [value_regex]] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --get name [value_regex] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --get-all name [value_regex] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --unset name [value_regex] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --unset-all name [value_regex] +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --rename-section old_name new_name +'git-config' [--system | --global | --remote=[<host>:]<directory ] + [type] --remove-section name +'git-config' [--system | --global | --remote=[<host>:]<directory ] -l | --list DESCRIPTION -----------
@@ -80,6 +89,10 @@ OPTIONS Use system-wide $(prefix)/etc/gitconfig rather than the repository .git/config. +--remote=[<host>:]<directory + Use remote config instead of the repository .git/config. + Only available for reading options. + --remove-section:: Remove the given section from the configuration file.
builtin-config.c +34 -10
83 lines not on this page · raw message
cache.h +1 -0
@@ -499,6 +499,7 @@ extern int update_server_info(int);typedef int (*config_fn_t )(const char *,const char *);extern int git_default_config (const char *,const char *);extern int git_config_from_file (config_fn_t fn,const char *); +extern int git_config_from_remote (config_fn_t fn,char *dest);extern int git_config (config_fn_t fn);extern int git_config_int (const char *,const char *);extern int git_config_bool (const char *,const char *);
config.c +26 -0
@@ -6,9 +6,12 @@* */ #include "cache.h" +#include "pkt-line.h" #define MAXNAME (256) +static const char *dumpconfig ="git-dump-config" ; +static FILE *config_file;static const char *config_file_name;static int config_linenr;
@@ -392,6 +395,29 @@ int git_config_from_file(config_fn_t fn, const char *filename)return ret; } +int git_config_from_remote (config_fn_t fn,char *dest) +{ +int ret; +int fd[2 ]; +pid_t pid; +static char var[MAXNAME ]; +static char value[1024 ]; + + pid =git_connect (fd, dest, dumpconfig); +if (pid <0 ) +return 1 ; + ret =0 ; +while (packet_read_line (fd[0 ], var,sizeof (var))) { +if (!packet_read_line (fd[0 ], value,sizeof (value))) +die ("Missing value" ); +fn (var, value); + } +close (fd[0 ]); +close (fd[1 ]); + ret |=finish_connect (pid); +return !!ret; +} +int git_config (config_fn_t fn) {int ret =0 ;
Signature · 1 line
1.5.2.rc1.25.g889f-dirty
PATCH 1/1 git-clone: add --submodules for cloning submodules
In reply to Sven VerdoolaegeFrom: Sven Verdoolaege <[email protected]>
When the --submodules option is specified, git-clone will search for submodule.<submodule>.url options in the remote configuration and clone each submodule using the first url that it can use from the local site.
The submodules are currently not checked out.
--- Documentation/config.txt | 3 ++ Documentation/git-clone.txt | 6 +++- git-clone.sh | 68 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 2 deletions(-)
Documentation/config.txt +3 -0
@@ -597,6 +597,9 @@ showbranch.default:: The default set of branches for gitlink:git-show-branch[1]. See gitlink:git-show-branch[1]. +submodule.<submodule>.url + The URL of a submodule. See gitlink:git-clone[1]. + tar.umask:: By default, gitlink:git-tar-tree[1] sets file and directories modes to 0666 or 0777. While this is both useful and acceptable for projects
Documentation/git-clone.txt +5 -1
@@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>] [--reference <repository>] - [--depth <depth>] <repository> [<directory>] + [--depth <depth>] [--submodules] <repository> [<directory>] DESCRIPTION -----------
@@ -105,6 +105,10 @@ OPTIONS with a long history, and would want to send in a fixes as patches. +--submodules:: + Clone submodules specified in (remote) configuration parameters + submodule.<submodule>.url. + <repository>:: The (possibly remote) repository to clone from. It can be any URL git-fetch supports.
git-clone.sh +67 -1
104 lines not on this page · raw message
Signature · 1 line
1.5.2.rc1.25.g889f-dirty