summaryrefslogtreecommitdiff
path: root/t/t7400-submodule-basic.sh
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2019-11-25 04:15:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-25 05:08:25 (GMT)
commit1f3aea22c781d603d56ce794879a8fe8d8dd77d1 (patch)
tree2885e4bdb247daa8a8e8227cc1c433c943821a04 /t/t7400-submodule-basic.sh
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
downloadgit-1f3aea22c781d603d56ce794879a8fe8d8dd77d1.zip
git-1f3aea22c781d603d56ce794879a8fe8d8dd77d1.tar.gz
git-1f3aea22c781d603d56ce794879a8fe8d8dd77d1.tar.bz2
submodule: fix 'submodule status' when called from a subdirectory
When calling `git submodule status` while in a subdirectory, we are incorrectly not detecting modified submodules and thus reporting that all of the submodules are unchanged. This is because the submodule helper is calling `diff-index` with the submodule path assuming the path is relative to the current prefix directory, however the submodule path used is actually relative to the root. Always pass NULL as the `prefix` when running diff-files on the submodule, to make sure the submodule's path is interpreted as relative to the superproject's repository root. Signed-off-by: Manish Goregaokar <manishsmail@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7400-submodule-basic.sh')
-rwxr-xr-xt/t7400-submodule-basic.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index a208cb2..7382f50 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -356,6 +356,28 @@ test_expect_success 'status should only print one line' '
test_line_count = 1 lines
'
+test_expect_success 'status from subdirectory should have the same SHA1' '
+ test_when_finished "rmdir addtest/subdir" &&
+ (
+ cd addtest &&
+ mkdir subdir &&
+ git submodule status >output &&
+ awk "{print \$1}" <output >expect &&
+ cd subdir &&
+ git submodule status >../output &&
+ awk "{print \$1}" <../output >../actual &&
+ test_cmp ../expect ../actual &&
+ git -C ../submod checkout HEAD^ &&
+ git submodule status >../output &&
+ awk "{print \$1}" <../output >../actual2 &&
+ cd .. &&
+ git submodule status >output &&
+ awk "{print \$1}" <output >expect2 &&
+ test_cmp expect2 actual2 &&
+ ! test_cmp actual actual2
+ )
+'
+
test_expect_success 'setup - fetch commit name from submodule' '
rev1=$(cd .subrepo && git rev-parse HEAD) &&
printf "rev1: %s\n" "$rev1" &&