summaryrefslogtreecommitdiff
path: root/t/t7506-status-submodule.sh
diff options
context:
space:
mode:
authorJens Lehmann <Jens.Lehmann@web.de>2010-04-10 17:01:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-04-10 18:51:56 (GMT)
commiteee49b6ce4b7b3fed28794676c67ad3609f658ac (patch)
treeec4ee07b1434745d84e28b3d73095ee9a652fcde /t/t7506-status-submodule.sh
parent3bfc45047654c7dd38b32033321228e97fc8f60e (diff)
downloadgit-eee49b6ce4b7b3fed28794676c67ad3609f658ac.zip
git-eee49b6ce4b7b3fed28794676c67ad3609f658ac.tar.gz
git-eee49b6ce4b7b3fed28794676c67ad3609f658ac.tar.bz2
Teach diff --submodule and status to handle .git files in submodules
The simple test for an existing .git directory gives an incorrect result if .git is a file that records "gitdir: overthere". So for submodules that use a .git file, "git status" and the diff family - when the "--submodule" option is given - did assume the submodule was not populated at all when a .git file was used, thus generating wrong output or no output at all. This is fixed by using read_gitfile_gently() to get the correct location of the .git directory. While at it, is_submodule_modified() was cleaned up to use the "dir" member of "struct child_process" instead of setting the GIT_WORK_TREE and GIT_DIR environment variables. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7506-status-submodule.sh')
-rwxr-xr-xt/t7506-status-submodule.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
index aeec1f6..3d4f85d 100755
--- a/t/t7506-status-submodule.sh
+++ b/t/t7506-status-submodule.sh
@@ -157,6 +157,22 @@ test_expect_success 'status with added and untracked file in modified submodule
EOF
'
+test_expect_success 'setup .git file for sub' '
+ (cd sub &&
+ rm -f new-file
+ REAL="$(pwd)/../.real" &&
+ mv .git "$REAL"
+ echo "gitdir: $REAL" >.git) &&
+ echo .real >>.gitignore &&
+ git commit -m "added .real to .gitignore" .gitignore
+'
+
+test_expect_success 'status with added file in modified submodule with .git file' '
+ (cd sub && git reset --hard && echo >foo && git add foo) &&
+ git status >output &&
+ grep "modified: sub (new commits, modified content)" output
+'
+
test_expect_success 'rm submodule contents' '
rm -rf sub/* sub/.git
'