path: root/t/
diff options
authorStefan Beller <>2018-10-16 17:27:03 (GMT)
committerJunio C Hamano <>2018-10-18 02:10:29 (GMT)
commite0a862fdaf7628ceba4ea290b91ffd5d3c46b75b (patch)
treed9ac2d128bd5be4a7b6da2c89df95c85b3e51370 /t/
parentcae598d9980661a978e2df4fb338518f7bf09572 (diff)
submodule helper: convert relative URL to absolute URL if needed
The submodule helper update_clone called by "git submodule update", clones submodules if needed. As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuring When trying to obtain submodules that are set active this way, we'll fallback to the URL found in the .gitmodules, which may be relative to the superproject, but we do not resolve it, yet: git clone cd gerrit && grep url .gitmodules url = ../plugins/codemirror-editor ... git config . git submodule update fatal: repository '../plugins/codemirror-editor' does not exist fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed Failed to clone 'plugins/codemirror-editor'. Retry scheduled [...] fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed Failed to clone 'plugins/codemirror-editor' a second time, aborting [...] To resolve the issue, factor out the function that resolves the relative URLs in "git submodule init" (in the submodule helper in the init_submodule function) and call it at the appropriate place in the update_clone helper. Reported-by: Jaewoong Jung <> Signed-off-by: Stefan Beller <> Reviewed-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 24 insertions, 0 deletions
diff --git a/t/ b/t/
index c0ffc10..76a7cb0 100755
--- a/t/
+++ b/t/
@@ -1224,6 +1224,30 @@ test_expect_success 'submodule update and setting submodule.<name>.active' '
test_cmp expect actual
+test_expect_success 'clone active submodule without submodule url set' '
+ test_when_finished "rm -rf test/test" &&
+ mkdir test &&
+ # another dir breaks accidental relative paths still being correct
+ git clone file://"$pwd"/multisuper test/test &&
+ (
+ cd test/test &&
+ git config "." &&
+ # do not pass --init flag, as the submodule is already active:
+ git submodule update &&
+ git submodule status >actual_raw &&
+ cut -c 1,43- actual_raw >actual &&
+ cat >expect <<-\EOF &&
+ sub0 (test2)
+ sub1 (test2)
+ sub2 (test2)
+ sub3 (test2)
+ test_cmp expect actual
+ )
test_expect_success 'clone --recurse-submodules with a pathspec works' '
test_when_finished "rm -rf multisuper_clone" &&
cat >expected <<-\EOF &&