fetch/pull: Don't recurse into a submodule when commits are already present
[gitweb.git] / t / t5526-fetch-submodules.sh
index 09701aa1a71fa51b54fd2bf68858437eb63c1ee2..3decfae6e0957c0f2e2499ec06ff6ab4227da8b9 100755 (executable)
@@ -428,4 +428,23 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override
        test_cmp expect.err.2 actual.err
 '
 
+test_expect_success "don't fetch submodule when newly recorded commits are already present" '
+       (
+               cd submodule &&
+               git checkout -q HEAD^^
+       ) &&
+       head1=$(git rev-parse --short HEAD) &&
+       git add submodule &&
+       git commit -m "submodule rewound" &&
+       head2=$(git rev-parse --short HEAD) &&
+       echo "From $pwd/." > expect.err &&
+       echo "   $head1..$head2  master     -> origin/master" >> expect.err &&
+       (
+               cd downstream &&
+               git fetch >../actual.out 2>../actual.err
+       ) &&
+       ! test -s actual.out &&
+       test_cmp expect.err actual.err
+'
+
 test_done