Re: [PATCH 2/5] git-config: add --remote option for reading config from remote repo

Previous thread: none

Next thread: Re: [git-svn PATCH] Add --no-rebase option to git-svn dcommit by davidk on Friday, May 4, 2007 - 5:08 am. (1 message)
To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

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
-

To: Sven Verdoolaege <skimo@...>
Cc: <git@...>
Date: Friday, May 4, 2007 - 6:52 pm

The plumbing part looks very good, although I sensed a slight
slop toward the end (will comment on individual patches later).

I do not like the Porcelain part very much, though. I do not
think we would want to add anything new to git-clone. We should
lose as much code from git-clone that is common with git-fetch
as we can first, and add new features to git-fetch, with
possibly passthru options added to git-clone as needed (e.g. a
new --submodule option).

If you --submodule cloned a remote repository when it had two
submodules, and then later the remote adds another submodule,
you would need to have a way to fetch that can discover the
presense of the new submodule and add it for you, and at that
point, having the code that knows much about submodules in clone
would not help you much.

I suspect that a possible interaction between git-fetch and
git-clone would go like this:

(1) "git-clone [--submodules]" would perform a normal clone,
having most of its work done by git-remote and git-fetch;

(2) when "--submodules" is given to "git-clone", it passes it
through to underlying "git-fetch";

(3) "git-fetch --submodules", after finishing what it would do
without "--submodules" option, would inspect the fetched
tree (or the index derived from it), find the tree entries
with mode 160000 (i.e. submodule graft points), and _then_
uses the pathnames of these tree entries to consult the
config mechanism to see which URL(s) can be used to
retrieve them, probably only for new submodules. Your new
"config --remote" mechanism may be one good way to prime
the configuration from the originating site.

We could probably extend the upload-pack protocol to send the
same information as you are using submodules.*.url for, instead
of adding a yet another protocol and program pairs you used for
"git config --remote". Having a generic program and protocol to
dump the whole configuration file is certainly simpler, easier
to debug, and easie...

To: Junio C Hamano <junkio@...>
Cc: <git@...>
Date: Friday, May 18, 2007 - 3:33 pm

I've gone for cloning all available submodules on the remote,
even if they are not used in the HEAD.
A submodule may have been removed already and IMHO, you wouldn't
want to clone a submodule at the time you reset to an intermediate
commit.

skimo
-

To: Junio C Hamano <junkio@...>
Cc: <git@...>
Date: Saturday, May 5, 2007 - 4:14 am

We could easily have dump-config only dump a predefined "known safe"
set of config options, although that would mean you have to upgrade
the server side each time you add a new dumpable config option.
Or we could do the preselection only when called from git-daemon.

skimo
-

To: <skimo@...>
Cc: Junio C Hamano <junkio@...>, <git@...>
Date: Sunday, May 6, 2007 - 12:13 am

Or we could have the set of dumpable options itself in the config file;
a bit more cumbersome, but leaves all flexibility (including the
shoot-yourself-in-the-foot kind) in the hands of the users :)

-az

-

To: <skimo@...>
Cc: <git@...>
Date: Saturday, May 5, 2007 - 4:46 am

- Figuring out the name of the new directory we create (think
"git clone git://repo.or.cz/git.git" -- it does "mkdir git &&
cd git" for you before doing the other things).

- Run "git init" there, obviously.

- Probably run "git ls-remote" to figure out which branch HEAD
should point at; you would definitely want to add a mechanism
to pass the ls-remote result to the "git fetch" you are going
to call next, as it is the first thing "git fetch" usually
does -- we would want to reuse it.

- Recently suggested good addition is to have "--track $branch"
option to "git clone" to point remotes/origin/HEAD to
something other than what the remote's HEAD actually points
at (the discussion was primarily between Carl Worth and
Linus; see archive).

- Run "git remote add origin" with the given URL to set up the
standard "separate remotes" tracking structure.

- Run "git fetch" for initial fetch ("git remote add -f" could
do that as well). You would probably need to pass --tags to
this "git fetch" to mimick what "git clone" does today.

Most likely yes but that is just my gut feeling -- I readily
admit I haven't thought it through.

-

To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

This allows us to use the methods provided by http.c
from within libgit, in particular config.c.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
http-fetch.c | 5 ++++-
http-push.c | 5 ++++-
http.h | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/http-fetch.c b/http-fetch.c
index 09baedc..53fb2a9 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -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:");
diff --git a/http-push.c b/http-push.c
index e3f7675..d4c850b 100644
--- a/http-push.c
+++ b/http-push.c
@@ -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:");
diff --git a/http.h b/http.h
index 69b6b66..7a41cde 100644
--- a/http.h
+++ b/http.h
@@ -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_slo...

To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

This command dumps the config of a repository and will be used
to read config options from a remote site.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
.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

diff --git a/.gitignore b/.gitignore
index 4dc0c39..d4e5492 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 443802a..fa04615 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -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
diff --git a/Documentation/git-dump-config.txt b/Documentation/git-dump-config.txt
new file mode 100644
index 0000000..370781c
--- /dev/null
+++ b/Documentation/git-dump-config.txt
@@ -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 --rem...

To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
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

diff --git a/Makefile b/Makefile
index 0185386..b782111 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/config.c b/config.c
index 0da74e0..36e3b97 100644
--- a/config.c
+++ b/config.c
@@ -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[MA...

To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

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.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
Documentation/config.txt | 3 ++
Documentation/git-clone.txt | 6 +++-
git-clone.sh | 68 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 24f9655..92747d8 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 6d32c49..b112a6a 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -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-fetc...

To: <git@...>
Cc: Sven Verdoolaege <skimo@...>
Date: Friday, May 4, 2007 - 6:56 am

From: Sven Verdoolaege <skimo@kotnet.org>

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
Documentation/git-config.txt | 33 +++++++++++++++++++++---------
builtin-config.c | 44 ++++++++++++++++++++++++++++++++---------
cache.h | 1 +
config.c | 26 ++++++++++++++++++++++++
4 files changed, 84 insertions(+), 20 deletions(-)

diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 280ef20..76398ab 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -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 | --rem...

To: Sven Verdoolaege <skimo@...>
Cc: <git@...>
Date: Friday, May 4, 2007 - 5:03 pm

Some comments on the documentation:

maybe something more like

'git-config' [ scope ]

where you mention later that scope can be --system | --global | --remote

Why did you add it to all options in the SYNOPSYS then?

Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
-

To: Frank Lichtenheld <frank@...>
Cc: <git@...>
Date: Friday, May 4, 2007 - 5:10 pm

Because I wasn't thinking.

skimo
-

To: Sven Verdoolaege <skimo@...>
Cc: <git@...>
Date: Friday, May 4, 2007 - 5:35 pm

Note that this is inconsistent with the rest of the documentation

Another small error: You seem to be missing a '>' after each occourence of
'<directory'.

Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
-

Previous thread: none

Next thread: Re: [git-svn PATCH] Add --no-rebase option to git-svn dcommit by davidk on Friday, May 4, 2007 - 5:08 am. (1 message)