submodule init: warn about falling back to a local path
PATCH 1/1 submodule init: warn about falling back to a local path
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
This can be confusing to users as there is a lot of guessing involved, which is not obvious to the user.
So in the corner case of assuming a local autoritative truth, warn the user to lessen the confusion.
This behavior was introduced in 4d6893200 (submodule add: allow relative repository path even when no url is set, 2011-06-06), which shared the code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).
In case of submodule-add, this behavior makes sense in some use cases[1], however for submodule-init there does not seem to be an immediate obvious use case to fall back to a local submodule. However there might be, so warn instead of die here.
[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"
--- builtin/submodule--helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
builtin/submodule--helper.c +3 -5
@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote); -if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { remoteurl =xgetcwd (); +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf); + } relurl =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb);free (remoteurl);
Signature · 1 line
2.12.0.rc1.16.ge4278d41a0.dirty
From: "Stefan Beller" <[email protected]>
Quoted 11 lines
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
This can be confusing to users as there is a lot of guessing involved, which is not obvious to the user.
Would a note in the user docs about the fallback you list above also be useful?
Quoted 14 lines
So in the corner case of assuming a local autoritative truth, warn the user to lessen the confusion.
This behavior was introduced in
4d6893200(submodule add: allow relative repository path even when no url is set, 2011-06-06), which shared the code with submodule-init and then ported to C in3604242f080a(submodule:
port init from shell to C, 2016-04-15).In case of submodule-add, this behavior makes sense in some use cases[1], however for submodule-init there does not seem to be an immediate obvious use case to fall back to a local submodule. However there might be, so warn instead of die here.
Quoted 9 lines
[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"Reported-by Shawn Pearce <[email protected]>Signed-off-by Stefan Beller <[email protected]>---
builtin/submodule--helper.c| 8 +++-----1 file changed, 3 insertions(+), 5 deletions(-)
--
Philip
Quoted 3 lines · Philip Oakley
Would a note in the user docs about the fallback you list above also be useful?
duh! yes it would! Will look at the documentation and reroll.
PATCH 1/1 submodule init: warn about falling back to a local path
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
This can be confusing to users as there is a lot of guessing involved, which is not obvious to the user.
So in the corner case of assuming a local autoritative truth, warn the user to lessen the confusion.
This behavior was introduced in 4d6893200 (submodule add: allow relative repository path even when no url is set, 2011-06-06), which shared the code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).
In case of submodule-add, this behavior makes sense in some use cases[1], however for submodule-init there does not seem to be an immediate obvious use case to fall back to a local submodule. However there might be, so warn instead of die here.
While adding the warning, also clarify the behavior of relative URLs in the documentation.
[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"
--- Documentation/git-submodule.txt | 22 +++++++++++++++------- builtin/submodule--helper.c | 8 +++----- 2 files changed, 18 insertions(+), 12 deletions(-)
Documentation/git-submodule.txt +15 -7
@@ -73,13 +73,17 @@ configuration entries unless `--name` is used to specify a logical name. + <repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./ -or ../), the location relative to the superproject's origin +or ../), the location relative to the superproject's default remote repository (Please note that to specify a repository 'foo.git' which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories). -If the superproject doesn't have an origin configured ++ +The default remote is the remote of the remote tracking branch +of the current branch. If no such remote tracking branch exists or +the in detached HEAD mode, "origin" is assumed to be the default remote. +If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current working directory is used instead. +
@@ -118,18 +122,22 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. + added and committed elsewhere) by copying `submodule.$name.url` + from .gitmodules to .git/config, resolving relative urls to be + relative to the default remote. ++ Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config. - The key used in .git/config is `submodule.$name.url`. + If no path is specified all submodules are initialized. ++ + When present, it will also copy the value of `submodule.$name.update`. This command does not alter existing information in .git/config. You can then customize the submodule clone URLs in .git/config for your local setup and proceed to `git submodule update`; you can also just use `git submodule update --init` without the explicit 'init' step if you do not intend to customize any submodule locations. ++ + See the add subcommand for the defintion of default remote. deinit [-f|--force] (--all|[--] <path>...):: Unregister the given submodules, i.e. remove the whole
builtin/submodule--helper.c +3 -5
@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote); -if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { remoteurl =xgetcwd (); +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf); + } relurl =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb);free (remoteurl);
Signature · 1 line
2.12.0.rc1.16.ge4278d41a0.dirty
Am 24.02.2017 um 01:17 schrieb Stefan Beller:
Documentation/git-submodule.txt configuration entries unless `--name` is used to specify a logical name. · line 85
Quoted 7 lines
Documentation/git-submodule.txt +3
-0@@ -73,13 +73,17 @@ configuration entries unless `--name` is used to specify a logical name. +The default remote is the remote of the remote tracking branch +of the current branch. If no such remote tracking branch exists or +the in detached HEAD mode, "origin" is assumed to be the default remote.
The part after "or" does not quite parse.
Quoted 19 lines
Documentation/git-submodule.txt +6
-5+If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current working directory is used instead. +@@ -118,18 +122,22 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. + added and committed elsewhere) by copying `submodule.$name.url` + from .gitmodules to .git/config, resolving relative urls to be + relative to the default remote. ++ Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config. - The key used in .git/config is `submodule.$name.url`. + If no path is specified all submodules are initialized.
Documentation/git-submodule.txt too (and can also report changes to a submodule's work tree). · line 140
Quoted 10 lines
Documentation/git-submodule.txt +4
-0++ + When present, it will also copy the value of `submodule.$name.update`. This command does not alter existing information in .git/config. You can then customize the submodule clone URLs in .git/config for your local setup and proceed to `git submodule update`; you can also just use `git submodule update --init` without the explicit 'init' step if you do not intend to customize any submodule locations. ++ + See the add subcommand for the defintion of default remote.
To be rendered correctly, I think you must remove the indentation from continuation paragraphs.
Quoted 10 lines
Documentation/git-submodule.txt +0
-0deinit [-f|--force] (--all|[--] <path>...):: Unregister the given submodules, i.e. remove the wholebuiltin/submodule--helper.c +0
-0@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote);
builtin/submodule--helper.c static void init_submodule(const char *path, const char *prefix, int quiet) · line 362
Quoted 10 lines
builtin/submodule--helper.c +3
-5-if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { remoteurl =xgetcwd (); +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf); + }
If you re-roll this patch, please place the warning before xgetcwd, which can potentially fail.
-- Hannes
PATCH 1/1 submodule init: warn about falling back to a local path
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
This can be confusing to users as there is a lot of guessing involved, which is not obvious to the user.
So in the corner case of assuming a local autoritative truth, warn the user to lessen the confusion.
This behavior was introduced in 4d6893200 (submodule add: allow relative repository path even when no url is set, 2011-06-06), which shared the code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).
In case of submodule-add, this behavior makes sense in some use cases[1], however for submodule-init there does not seem to be an immediate obvious use case to fall back to a local submodule. However there might be, so warn instead of die here.
While adding the warning, also clarify the behavior of relative URLs in the documentation.
[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"
---
* reworded sentence to not omit half of it.
* tested rendering to be correct
* warn before xgetcwd
Thanks,
Stefan
Documentation/git-submodule.txt | 36 ++++++++++++++++++++++-------------- builtin/submodule--helper.c | 8 +++----- 2 files changed, 25 insertions(+), 19 deletions(-)
Documentation/git-submodule.txt +22 -14
@@ -73,13 +73,17 @@ configuration entries unless `--name` is used to specify a logical name. + <repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./ -or ../), the location relative to the superproject's origin +or ../), the location relative to the superproject's default remote repository (Please note that to specify a repository 'foo.git' which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories). -If the superproject doesn't have an origin configured ++ +The default remote is the remote of the remote tracking branch +of the current branch. If no such remote tracking branch exists or +the HEAD is detached, "origin" is assumed to be the default remote. +If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current working directory is used instead. +
@@ -118,18 +122,22 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. - Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config. - The key used in .git/config is `submodule.$name.url`. - This command does not alter existing information in .git/config. - You can then customize the submodule clone URLs in .git/config - for your local setup and proceed to `git submodule update`; - you can also just use `git submodule update --init` without - the explicit 'init' step if you do not intend to customize - any submodule locations. + added and committed elsewhere) by copying `submodule.$name.url` + from .gitmodules to .git/config, resolving relative urls to be + relative to the default remote. ++ +Optional <path> arguments limit which submodules will be initialized. +If no path is specified all submodules are initialized. ++ +When present, it will also copy the value of `submodule.$name.update`. +This command does not alter existing information in .git/config. +You can then customize the submodule clone URLs in .git/config +for your local setup and proceed to `git submodule update`; +you can also just use `git submodule update --init` without +the explicit 'init' step if you do not intend to customize +any submodule locations. ++ +See the add subcommand for the defintion of default remote. deinit [-f|--force] (--all|[--] <path>...):: Unregister the given submodules, i.e. remove the whole
builtin/submodule--helper.c +3 -5
@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote); -if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf); remoteurl =xgetcwd (); + } relurl =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb);free (remoteurl);
Signature · 1 line
2.12.0.rc1.16.ge4278d41a0.dirty
Quoted 8 lines · Stefan Beller
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
IOW we keep the .url to be relative, the same as the original one we took from .gitmodules? That sounds like a sensible thing to do and I agree it makes sense to warn when it happens.
Quoted 5 lines
<repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./
Documentation/git-submodule.txt +1
-1-or ../), the location relative to the superproject's origin +or ../), the location relative to the superproject's default remote repository (Please note that to specify a repository 'foo.git'
Documentation/git-submodule.txt configuration entries unless `--name` is used to specify a logical name. · line 86
Quoted 10 lines
Documentation/git-submodule.txt +5
-1which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories). -If the superproject doesn't have an origin configured ++ +The default remote is the remote of the remote tracking branch +of the current branch. If no such remote tracking branch exists or +the HEAD is detached, "origin" is assumed to be the default remote. +If the superproject doesn't have a default remote configured
OK.
Quoted 9 lines
Documentation/git-submodule.txt +0
-5@@ -118,18 +122,22 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. - Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config.
Documentation/git-submodule.txt too (and can also report changes to a submodule's work tree). · line 127
Quoted 10 lines
Documentation/git-submodule.txt +3
-7- The key used in .git/config is `submodule.$name.url`. - This command does not alter existing information in .git/config. - You can then customize the submodule clone URLs in .git/config - for your local setup and proceed to `git submodule update`; - you can also just use `git submodule update --init` without - the explicit 'init' step if you do not intend to customize - any submodule locations. + added and committed elsewhere) by copying `submodule.$name.url` + from .gitmodules to .git/config, resolving relative urls to be + relative to the default remote.
I read this as "copying..., resolving relative to the default remote (if exists)." A reader would wonder what happens if the default remote does not exist---don't we want to describe what happens in that case, like, "recording . (the current repository) as the upstream" or something?
Documentation/git-submodule.txt too (and can also report changes to a submodule's work tree). · line 130
Quoted 3 lines
Documentation/git-submodule.txt +3
-0++ +Optional <path> arguments limit which submodules will be initialized. +If no path is specified all submodules are initialized.
Perhaps s/ all submodules/,&/?
Quoted 7 lines
Documentation/git-submodule.txt +0
-0deinit [-f|--force] (--all|[--] <path>...):: Unregister the given submodules, i.e. remove the wholebuiltin/submodule--helper.c +0
-0
builtin/submodule--helper.c static void init_submodule(const char *path, const char *prefix, int quiet) · line 360
Quoted 10 lines
builtin/submodule--helper.c +2
-5@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote); -if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf);
Sounds sensible (it might be a bit too long but it should be OK).
builtin/submodule--helper.c static void init_submodule(const char *path, const char *prefix, int quiet) · line 365
Quoted 5 lines
builtin/submodule--helper.c +1
-0remoteurl =xgetcwd (); + } relurl =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb);free (remoteurl);
Thanks.
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Stefan Beller
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
Quoted 5 lines
Quoted 2 lines
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
IOW we keep the .url to be relative, the same as the original one we took from .gitmodules?
Well that is one way to say that. Another way is:
If we cannot construct a URL based on the given relative URL, we demote the relative URL to be a relative PATH and resolve that instead.
Quoted 2 lines
That sounds like a sensible thing to do and
I agree it makes sense to warn when it happens.
ok.
Quoted 18 lines
Quoted 18 lines
Documentation/git-submodule.txt +1
-12@@ -118,18 +122,22 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. - Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config. - The key used in .git/config is `submodule.$name.url`. - This command does not alter existing information in .git/config. - You can then customize the submodule clone URLs in .git/config - for your local setup and proceed to `git submodule update`; - you can also just use `git submodule update --init` without - the explicit 'init' step if you do not intend to customize - any submodule locations. + added and committed elsewhere) by copying `submodule.$name.url`
Quoted 8 lines
Documentation/git-submodule.txt too (and can also report changes to a submodule's work tree). · line 127
Quoted 2 lines
Documentation/git-submodule.txt +2
-0+ from .gitmodules to .git/config, resolving relative urls to be + relative to the default remote.I read this as "copying..., resolving relative to the default remote (if exists)." A reader would wonder what happens if the default remote does not exist---don't we want to describe what happens in that case, like, "recording . (the current repository) as the upstream" or something?
eh, a better approach is s/copying/<something else>/ We will resolve the relative URL no matter what. It's just that we may end up with an absolute path instead of an absolute URL.
Quoted 6 lines
Documentation/git-submodule.txt too (and can also report changes to a submodule's work tree). · line 130
Quoted 4 lines
Documentation/git-submodule.txt +3
-0++ +Optional <path> arguments limit which submodules will be initialized. +If no path is specified all submodules are initialized.Perhaps s/ all submodules/,&/?
ok
Will reroll, once I have found a better wording.
PATCH 1/1 submodule init: warn about falling back to a local path
When a submodule is initialized, the config variable 'submodule.<name>.url' is set depending on the value of the same variable in the .gitmodules file. When the URL indicates to be relative, then the url is computed relative to its default remote. The default remote cannot be determined accurately in all cases, such that it falls back to 'origin'.
The 'origin' remote may not exist, though. In that case we give up looking for a suitable remote and we'll just assume it to be a local relative path.
This can be confusing to users as there is a lot of guessing involved, which is not obvious to the user.
So in the corner case of assuming a local autoritative truth, warn the user to lessen the confusion.
This behavior was introduced in 4d6893200 (submodule add: allow relative repository path even when no url is set, 2011-06-06), which shared the code with submodule-init and then ported to C in 3604242f080a (submodule:
port init from shell to C, 2016-04-15).
In case of submodule-add, this behavior makes sense in some use cases[1], however for submodule-init there does not seem to be an immediate obvious use case to fall back to a local submodule. However there might be, so warn instead of die here.
While adding the warning, also clarify the behavior of relative URLs in the documentation.
[1] e.g. http://stackoverflow.com/questions/8721984/git-ignore-files-for-public-repository-but-not-for-private
"store a secret locally in a submodule, with no intention to publish it"
---
Quoted 1 line
Perhaps s/ all submodules/,&/?
done
Quoted 2 lines
I read this as "copying..., resolving relative to the default remote (if exists)."
reworded with shorter sentences:
Initialize the submodules recorded in the index (which were added and committed elsewhere) by setting submodule.$name.url in .git/config. It uses the same setting from .gitmodules as a template. If the URL is relative, it will be resolved using the default remote. If there is no default remote, the current repository will be assumed to be upstream.
...
next paragraph
Documentation/git-submodule.txt | 38 ++++++++++++++++++++++++-------------- builtin/submodule--helper.c | 8 +++----- 2 files changed, 27 insertions(+), 19 deletions(-)
Documentation/git-submodule.txt +24 -14
@@ -73,13 +73,17 @@ configuration entries unless `--name` is used to specify a logical name. + <repository> is the URL of the new submodule's origin repository. This may be either an absolute URL, or (if it begins with ./ -or ../), the location relative to the superproject's origin +or ../), the location relative to the superproject's default remote repository (Please note that to specify a repository 'foo.git' which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories). -If the superproject doesn't have an origin configured ++ +The default remote is the remote of the remote tracking branch +of the current branch. If no such remote tracking branch exists or +the HEAD is detached, "origin" is assumed to be the default remote. +If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current working directory is used instead. +
@@ -118,18 +122,24 @@ too (and can also report changes to a submodule's work tree). init [--] [<path>...]:: Initialize the submodules recorded in the index (which were - added and committed elsewhere) by copying submodule - names and urls from .gitmodules to .git/config. - Optional <path> arguments limit which submodules will be initialized. - It will also copy the value of `submodule.$name.update` into - .git/config. - The key used in .git/config is `submodule.$name.url`. - This command does not alter existing information in .git/config. - You can then customize the submodule clone URLs in .git/config - for your local setup and proceed to `git submodule update`; - you can also just use `git submodule update --init` without - the explicit 'init' step if you do not intend to customize - any submodule locations. + added and committed elsewhere) by setting `submodule.$name.url` + in .git/config. It uses the same setting from .gitmodules as + a template. If the URL is relative, it will be resolved using + the default remote. If there is no default remote, the current + repository will be assumed to be upstream. ++ +Optional <path> arguments limit which submodules will be initialized. +If no path is specified, all submodules are initialized. ++ +When present, it will also copy the value of `submodule.$name.update`. +This command does not alter existing information in .git/config. +You can then customize the submodule clone URLs in .git/config +for your local setup and proceed to `git submodule update`; +you can also just use `git submodule update --init` without +the explicit 'init' step if you do not intend to customize +any submodule locations. ++ +See the add subcommand for the defintion of default remote. deinit [-f|--force] (--all|[--] <path>...):: Unregister the given submodules, i.e. remove the whole
builtin/submodule--helper.c +3 -5
@@ -356,12 +356,10 @@ static void init_submodule(const char *path, const char *prefix, int quiet)strbuf_addf (&remotesb,"remote.%s.url" , remote);free (remote); -if (git_config_get_string (remotesb.buf, &remoteurl)) -/* -* The repository is its own -* authoritative upstream -*/ +if (git_config_get_string (remotesb.buf, &remoteurl)) { +warning (_ ("could not lookup configuration '%s'. Assuming this repository is its own authoritative upstream." ), remotesb.buf); remoteurl =xgetcwd (); + } relurl =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb);free (remoteurl);
Signature · 1 line
2.12.0.rc1.16.ge4278d41a0.dirty