Signed-off-by: Stefan Beller <sbel...@google.com>
---

This is just to test the corner case we're discussing.
Applies on top of origin/hv/fetch-moved-submodules-on-demand.


 t/t5526-fetch-submodules.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index a552ad4ead..c82d519e06 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -571,6 +571,7 @@ test_expect_success 'fetching submodule into a broken 
repository' '
 '
 
 test_expect_success "fetch new commits when submodule got renamed" '
+       test_when_finished "rm -rf downstream_rename" &&
        git clone . downstream_rename &&
        (
                cd downstream_rename &&
@@ -605,4 +606,45 @@ test_expect_success "fetch new commits when submodule got 
renamed" '
        test_cmp expect actual
 '
 
+test_expect_success "warn on submodule name/path clash, but new commits 
fetched in renamed" '
+       test_when_finished "rm -rf downstream_rename" &&
+       git clone . downstream_rename &&
+       (
+               cd downstream_rename &&
+               git submodule update --init &&
+# NEEDSWORK: we omitted --recursive for the submodule update here since
+# that does not work. See test 7001 for mv "moving nested submodules"
+# for details. Once that is fixed we should add the --recursive option
+# here.
+               git checkout -b rename &&
+               git mv submodule submodule_renamed &&
+               (
+                       cd submodule_renamed &&
+                       git checkout -b rename_sub &&
+                       echo a >a &&
+                       git add a &&
+                       git commit -ma &&
+                       git push origin rename_sub &&
+                       git rev-parse HEAD >../../expect
+               ) &&
+               git add submodule_renamed &&
+               git commit -m "update renamed submodule" &&
+               # produce collision, note that we use no submodule command
+               git clone ../submodule submodule &&
+               git add submodule &&
+               git commit -m "have new submodule at old path " &&
+               git push origin rename
+       ) &&
+       (
+               cd downstream &&
+               git fetch --recurse-submodules=on-demand 2>err &&
+               grep "collides with a submodule named" err &&
+               (
+                       cd submodule &&
+                       git rev-parse origin/rename_sub >../../actual
+               )
+       ) &&
+       test_cmp expect actual
+'
+
 test_done
-- 
2.14.0.rc0.3.g6c2e499285

Reply via email to