2009-10-23 13:25:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Support for verbose submodule differences in git diff
|
|
|
|
|
|
|
|
This test tries to verify the sanity of the --submodule option of git diff.
|
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
add_file () {
|
2012-11-30 12:37:35 +01:00
|
|
|
(
|
|
|
|
cd "$1" &&
|
|
|
|
shift &&
|
|
|
|
for name
|
|
|
|
do
|
|
|
|
echo "$name" >"$name" &&
|
|
|
|
git add "$name" &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "Add $name" || exit
|
|
|
|
done >/dev/null &&
|
|
|
|
git rev-parse --short --verify HEAD
|
|
|
|
)
|
2009-10-23 13:25:33 +02:00
|
|
|
}
|
|
|
|
commit_file () {
|
|
|
|
test_tick &&
|
|
|
|
git commit "$@" -m "Commit $*" >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
test_create_repo sm1 &&
|
|
|
|
add_file . foo >/dev/null
|
|
|
|
|
|
|
|
head1=$(add_file sm1 foo1 foo2)
|
2012-11-30 12:37:34 +01:00
|
|
|
fullhead1=$(cd sm1; git rev-parse --verify HEAD)
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'added submodule' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git add sm1 &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 0000000...$head1 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'added submodule, set diff.submodule' '
|
2012-11-13 16:42:45 +01:00
|
|
|
git config diff.submodule log &&
|
|
|
|
git add sm1 &&
|
|
|
|
git diff --cached >actual &&
|
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 0000000...$head1 (new submodule)
|
|
|
|
EOF
|
2012-11-13 16:42:45 +01:00
|
|
|
git config --unset diff.submodule &&
|
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2012-11-13 16:42:45 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success '--submodule=short overrides diff.submodule' '
|
2012-11-13 16:42:45 +01:00
|
|
|
test_config diff.submodule log &&
|
|
|
|
git add sm1 &&
|
|
|
|
git diff --submodule=short --cached >actual &&
|
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
new file mode 160000
|
|
|
|
index 0000000..$head1
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Subproject commit $fullhead1
|
|
|
|
EOF
|
2012-11-13 16:42:45 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2012-11-13 16:42:45 +01:00
|
|
|
|
2012-11-13 16:42:46 +01:00
|
|
|
test_expect_success 'diff.submodule does not affect plumbing' '
|
|
|
|
test_config diff.submodule log &&
|
|
|
|
git diff-index -p HEAD >actual &&
|
|
|
|
cat >expected <<-EOF &&
|
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
new file mode 160000
|
2012-11-26 14:54:28 +01:00
|
|
|
index 0000000..$head1
|
2012-11-13 16:42:46 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Subproject commit $fullhead1
|
|
|
|
EOF
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2009-10-23 13:25:33 +02:00
|
|
|
commit_file sm1 &&
|
|
|
|
head2=$(add_file sm1 foo3)
|
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule(forward)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head1..$head2:
|
|
|
|
> Add foo3
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule(forward)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff --submodule=log >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head1..$head2:
|
|
|
|
> Add foo3
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule(forward) --submodule' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff --submodule >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head1..$head2:
|
|
|
|
> Add foo3
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:34 +01:00
|
|
|
fullhead2=$(cd sm1; git rev-parse --verify HEAD)
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule(forward) --submodule=short' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff --submodule=short >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
index $head1..$head2 160000
|
|
|
|
--- a/sm1
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -1 +1 @@
|
|
|
|
-Subproject commit $fullhead1
|
|
|
|
+Subproject commit $fullhead2
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
commit_file sm1 &&
|
2010-09-07 03:42:54 +02:00
|
|
|
head3=$(
|
|
|
|
cd sm1 &&
|
|
|
|
git reset --hard HEAD~2 >/dev/null &&
|
2012-11-30 12:37:34 +01:00
|
|
|
git rev-parse --short --verify HEAD
|
2010-09-06 20:39:54 +02:00
|
|
|
)
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule(backward)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head2..$head3 (rewind):
|
|
|
|
< Add foo3
|
|
|
|
< Add foo2
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
head4=$(add_file sm1 foo4 foo5)
|
|
|
|
test_expect_success 'modified submodule(backward and forward)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head2...$head4:
|
|
|
|
> Add foo5
|
|
|
|
> Add foo4
|
|
|
|
< Add foo3
|
|
|
|
< Add foo2
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
commit_file sm1 &&
|
|
|
|
mv sm1 sm1-bak &&
|
|
|
|
echo sm1 >sm1 &&
|
|
|
|
head5=$(git hash-object sm1 | cut -c1-7) &&
|
|
|
|
git add sm1 &&
|
|
|
|
rm -f sm1 &&
|
|
|
|
mv sm1-bak sm1
|
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob), --cached' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff --submodule=log --cached >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head4...0000000 (submodule deleted)
|
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..$head5
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+sm1
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff --submodule=log >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
deleted file mode 100644
|
|
|
|
index $head5..0000000
|
|
|
|
--- a/sm1
|
|
|
|
+++ /dev/null
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-sm1
|
|
|
|
Submodule sm1 0000000...$head4 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
rm -rf sm1 &&
|
|
|
|
git checkout-index sm1
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head4...0000000 (submodule deleted)
|
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..$head5
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+sm1
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
rm -f sm1 &&
|
|
|
|
test_create_repo sm1 &&
|
|
|
|
head6=$(add_file sm1 foo6 foo7)
|
2012-11-30 12:37:34 +01:00
|
|
|
fullhead6=$(cd sm1; git rev-parse --verify HEAD)
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'nonexistent commit' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head4...$head6 (commits not present)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
commit_file
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'typechanged submodule(blob->submodule)' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
deleted file mode 100644
|
|
|
|
index $head5..0000000
|
|
|
|
--- a/sm1
|
|
|
|
+++ /dev/null
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-sm1
|
|
|
|
Submodule sm1 0000000...$head6 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
commit_file sm1 &&
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule is up to date' '
|
2010-01-24 15:09:00 +01:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
echo new > sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked content (untracked ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked content (dirty ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked content (all ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked and modifed content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains untracked and modifed content (all ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule contains modifed content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
rm -f sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
|
|
|
(cd sm1; git commit -mchange foo6 >/dev/null) &&
|
2012-11-30 12:37:34 +01:00
|
|
|
head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'submodule is modified' '
|
2010-01-24 15:09:00 +01:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
echo new > sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked content (untracked ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked content (dirty ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked content (all ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked and modifed content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' '
|
2010-06-08 18:31:51 +02:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
2010-06-25 19:20:48 +02:00
|
|
|
! test -s actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-06-08 18:31:51 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'modified submodule contains modifed content' '
|
2010-01-24 15:09:00 +01:00
|
|
|
rm -f sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2010-01-24 15:09:00 +01:00
|
|
|
|
2009-10-23 13:25:33 +02:00
|
|
|
rm -rf sm1
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'deleted submodule' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
test_create_repo sm2 &&
|
|
|
|
head7=$(add_file sm2 foo8 foo9) &&
|
|
|
|
git add sm2
|
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'multiple submodules' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'path filter' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD sm2 >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
|
|
|
commit_file sm2
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'given commit' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=log HEAD^ >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'given commit --submodule' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule HEAD^ >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2012-11-30 12:37:36 +01:00
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:34 +01:00
|
|
|
fullhead7=$(cd sm2; git rev-parse --verify HEAD)
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2012-11-30 12:37:36 +01:00
|
|
|
test_expect_success 'given commit --submodule=short' '
|
2009-10-23 13:25:33 +02:00
|
|
|
git diff-index -p --submodule=short HEAD^ >actual &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
diff --git a/sm1 b/sm1
|
|
|
|
deleted file mode 160000
|
|
|
|
index $head6..0000000
|
|
|
|
--- a/sm1
|
|
|
|
+++ /dev/null
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-Subproject commit $fullhead6
|
|
|
|
diff --git a/sm2 b/sm2
|
|
|
|
new file mode 160000
|
|
|
|
index 0000000..$head7
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm2
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Subproject commit $fullhead7
|
|
|
|
EOF
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
2009-10-23 13:25:33 +02:00
|
|
|
|
2010-04-10 19:01:12 +02:00
|
|
|
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 &&
|
2010-11-14 15:44:16 +01:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 12:37:36 +01:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 15:44:16 +01:00
|
|
|
test_cmp expected actual
|
2010-04-10 19:01:12 +02:00
|
|
|
'
|
|
|
|
|
2012-05-14 18:24:45 +02:00
|
|
|
test_expect_success 'diff --submodule with objects referenced by alternates' '
|
|
|
|
mkdir sub_alt &&
|
|
|
|
(cd sub_alt &&
|
|
|
|
git init &&
|
|
|
|
echo a >a &&
|
|
|
|
git add a &&
|
|
|
|
git commit -m a
|
|
|
|
) &&
|
|
|
|
mkdir super &&
|
|
|
|
(cd super &&
|
|
|
|
git clone -s ../sub_alt sub &&
|
|
|
|
git init &&
|
|
|
|
git add sub &&
|
|
|
|
git commit -m "sub a"
|
|
|
|
) &&
|
|
|
|
(cd sub_alt &&
|
|
|
|
sha1_before=$(git rev-parse --short HEAD)
|
|
|
|
echo b >b &&
|
|
|
|
git add b &&
|
|
|
|
git commit -m b
|
|
|
|
sha1_after=$(git rev-parse --short HEAD)
|
|
|
|
echo "Submodule sub $sha1_before..$sha1_after:
|
|
|
|
> b" >../expected
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd sub &&
|
|
|
|
git fetch &&
|
|
|
|
git checkout origin/master
|
|
|
|
) &&
|
|
|
|
git diff --submodule > ../actual
|
|
|
|
)
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2009-10-23 13:25:33 +02:00
|
|
|
test_done
|