summaryrefslogtreecommitdiff
path: root/t/t4041-diff-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/t4041-diff-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/t4041-diff-submodule.sh')
-rwxr-xr-xt/t4041-diff-submodule.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t4041-diff-submodule.sh b/t/t4041-diff-submodule.sh
index 11b1997..019acb9 100755
--- a/t/t4041-diff-submodule.sh
+++ b/t/t4041-diff-submodule.sh
@@ -329,4 +329,19 @@ index 0000000..$head7
EOF
"
+test_expect_success 'setup .git file for sm2' '
+ (cd sm2 &&
+ REAL="$(pwd)/../.real" &&
+ mv .git "$REAL"
+ echo "gitdir: $REAL" >.git)
+'
+
+test_expect_success 'diff --submodule with .git file' '
+ git diff --submodule HEAD^ >actual &&
+ diff actual - <<-EOF
+Submodule sm1 $head6...0000000 (submodule deleted)
+Submodule sm2 0000000...$head7 (new submodule)
+EOF
+'
+
test_done