Merge branch 'rr/t4041-cleanup'
* rr/t4041-cleanup: t4041 (diff-submodule-option): modernize style t4041 (diff-submodule-option): rewrite add_file() routine t4041 (diff-submodule-option): parse digests sensibly t4041 (diff-submodule-option): don't hardcode SHA-1 in expected outputs
This commit is contained in:
commit
7e2ef8b049
@ -11,18 +11,18 @@ This test tries to verify the sanity of the --submodule option of git diff.
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
add_file () {
|
add_file () {
|
||||||
sm=$1
|
(
|
||||||
shift
|
cd "$1" &&
|
||||||
owd=$(pwd)
|
shift &&
|
||||||
cd "$sm"
|
for name
|
||||||
for name; do
|
do
|
||||||
echo "$name" > "$name" &&
|
echo "$name" >"$name" &&
|
||||||
git add "$name" &&
|
git add "$name" &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m "Add $name"
|
git commit -m "Add $name" || exit
|
||||||
done >/dev/null
|
done >/dev/null &&
|
||||||
git rev-parse --verify HEAD | cut -c1-7
|
git rev-parse --short --verify HEAD
|
||||||
cd "$owd"
|
)
|
||||||
}
|
}
|
||||||
commit_file () {
|
commit_file () {
|
||||||
test_tick &&
|
test_tick &&
|
||||||
@ -33,43 +33,43 @@ test_create_repo sm1 &&
|
|||||||
add_file . foo >/dev/null
|
add_file . foo >/dev/null
|
||||||
|
|
||||||
head1=$(add_file sm1 foo1 foo2)
|
head1=$(add_file sm1 foo1 foo2)
|
||||||
fullhead1=$(cd sm1; git rev-list --max-count=1 $head1)
|
fullhead1=$(cd sm1; git rev-parse --verify HEAD)
|
||||||
|
|
||||||
test_expect_success 'added submodule' "
|
test_expect_success 'added submodule' '
|
||||||
git add sm1 &&
|
git add sm1 &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 0000000...$head1 (new submodule)
|
Submodule sm1 0000000...$head1 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'added submodule, set diff.submodule' "
|
test_expect_success 'added submodule, set diff.submodule' '
|
||||||
git config diff.submodule log &&
|
git config diff.submodule log &&
|
||||||
git add sm1 &&
|
git add sm1 &&
|
||||||
git diff --cached >actual &&
|
git diff --cached >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 0000000...$head1 (new submodule)
|
Submodule sm1 0000000...$head1 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
git config --unset diff.submodule &&
|
git config --unset diff.submodule &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success '--submodule=short overrides diff.submodule' "
|
test_expect_success '--submodule=short overrides diff.submodule' '
|
||||||
test_config diff.submodule log &&
|
test_config diff.submodule log &&
|
||||||
git add sm1 &&
|
git add sm1 &&
|
||||||
git diff --submodule=short --cached >actual &&
|
git diff --submodule=short --cached >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
new file mode 160000
|
new file mode 160000
|
||||||
index 0000000..a2c4dab
|
index 0000000..$head1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/sm1
|
+++ b/sm1
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
+Subproject commit $fullhead1
|
+Subproject commit $fullhead1
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'diff.submodule does not affect plumbing' '
|
test_expect_success 'diff.submodule does not affect plumbing' '
|
||||||
test_config diff.submodule log &&
|
test_config diff.submodule log &&
|
||||||
@ -77,7 +77,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
|
|||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
new file mode 160000
|
new file mode 160000
|
||||||
index 0000000..a2c4dab
|
index 0000000..$head1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/sm1
|
+++ b/sm1
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
@ -89,78 +89,77 @@ test_expect_success 'diff.submodule does not affect plumbing' '
|
|||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
head2=$(add_file sm1 foo3)
|
head2=$(add_file sm1 foo3)
|
||||||
|
|
||||||
test_expect_success 'modified submodule(forward)' "
|
test_expect_success 'modified submodule(forward)' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head1..$head2:
|
Submodule sm1 $head1..$head2:
|
||||||
> Add foo3
|
> Add foo3
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule(forward)' "
|
test_expect_success 'modified submodule(forward)' '
|
||||||
git diff --submodule=log >actual &&
|
git diff --submodule=log >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head1..$head2:
|
Submodule sm1 $head1..$head2:
|
||||||
> Add foo3
|
> Add foo3
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule(forward) --submodule' "
|
test_expect_success 'modified submodule(forward) --submodule' '
|
||||||
git diff --submodule >actual &&
|
git diff --submodule >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head1..$head2:
|
Submodule sm1 $head1..$head2:
|
||||||
> Add foo3
|
> Add foo3
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
fullhead2=$(cd sm1; git rev-list --max-count=1 $head2)
|
fullhead2=$(cd sm1; git rev-parse --verify HEAD)
|
||||||
test_expect_success 'modified submodule(forward) --submodule=short' "
|
test_expect_success 'modified submodule(forward) --submodule=short' '
|
||||||
git diff --submodule=short >actual &&
|
git diff --submodule=short >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
index $head1..$head2 160000
|
index $head1..$head2 160000
|
||||||
--- a/sm1
|
--- a/sm1
|
||||||
+++ b/sm1
|
+++ b/sm1
|
||||||
@@ -1 +1 @@
|
@@ -1 +1 @@
|
||||||
-Subproject commit $fullhead1
|
-Subproject commit $fullhead1
|
||||||
+Subproject commit $fullhead2
|
+Subproject commit $fullhead2
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
head3=$(
|
head3=$(
|
||||||
cd sm1 &&
|
cd sm1 &&
|
||||||
git reset --hard HEAD~2 >/dev/null &&
|
git reset --hard HEAD~2 >/dev/null &&
|
||||||
git rev-parse --verify HEAD | cut -c1-7
|
git rev-parse --short --verify HEAD
|
||||||
)
|
)
|
||||||
|
|
||||||
test_expect_success 'modified submodule(backward)' "
|
test_expect_success 'modified submodule(backward)' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head2..$head3 (rewind):
|
Submodule sm1 $head2..$head3 (rewind):
|
||||||
< Add foo3
|
< Add foo3
|
||||||
< Add foo2
|
< Add foo2
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
head4=$(add_file sm1 foo4 foo5) &&
|
head4=$(add_file sm1 foo4 foo5)
|
||||||
head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
|
test_expect_success 'modified submodule(backward and forward)' '
|
||||||
test_expect_success 'modified submodule(backward and forward)' "
|
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head2...$head4:
|
Submodule sm1 $head2...$head4:
|
||||||
> Add foo5
|
> Add foo5
|
||||||
> Add foo4
|
> Add foo4
|
||||||
< Add foo3
|
< Add foo3
|
||||||
< Add foo2
|
< Add foo2
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
mv sm1 sm1-bak &&
|
mv sm1 sm1-bak &&
|
||||||
@ -170,319 +169,319 @@ git add sm1 &&
|
|||||||
rm -f sm1 &&
|
rm -f sm1 &&
|
||||||
mv sm1-bak sm1
|
mv sm1-bak sm1
|
||||||
|
|
||||||
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
|
test_expect_success 'typechanged submodule(submodule->blob), --cached' '
|
||||||
git diff --submodule=log --cached >actual &&
|
git diff --submodule=log --cached >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 41fbea9...0000000 (submodule deleted)
|
Submodule sm1 $head4...0000000 (submodule deleted)
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..9da5fb8
|
index 0000000..$head5
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/sm1
|
+++ b/sm1
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
+sm1
|
+sm1
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'typechanged submodule(submodule->blob)' "
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
||||||
git diff --submodule=log >actual &&
|
git diff --submodule=log >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
index 9da5fb8..0000000
|
index $head5..0000000
|
||||||
--- a/sm1
|
--- a/sm1
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1 +0,0 @@
|
@@ -1 +0,0 @@
|
||||||
-sm1
|
-sm1
|
||||||
Submodule sm1 0000000...$head4 (new submodule)
|
Submodule sm1 0000000...$head4 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
rm -rf sm1 &&
|
rm -rf sm1 &&
|
||||||
git checkout-index sm1
|
git checkout-index sm1
|
||||||
test_expect_success 'typechanged submodule(submodule->blob)' "
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head4...0000000 (submodule deleted)
|
Submodule sm1 $head4...0000000 (submodule deleted)
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..$head5
|
index 0000000..$head5
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/sm1
|
+++ b/sm1
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
+sm1
|
+sm1
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
rm -f sm1 &&
|
rm -f sm1 &&
|
||||||
test_create_repo sm1 &&
|
test_create_repo sm1 &&
|
||||||
head6=$(add_file sm1 foo6 foo7)
|
head6=$(add_file sm1 foo6 foo7)
|
||||||
fullhead6=$(cd sm1; git rev-list --max-count=1 $head6)
|
fullhead6=$(cd sm1; git rev-parse --verify HEAD)
|
||||||
test_expect_success 'nonexistent commit' "
|
test_expect_success 'nonexistent commit' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head4...$head6 (commits not present)
|
Submodule sm1 $head4...$head6 (commits not present)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
commit_file
|
commit_file
|
||||||
test_expect_success 'typechanged submodule(blob->submodule)' "
|
test_expect_success 'typechanged submodule(blob->submodule)' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
index $head5..0000000
|
index $head5..0000000
|
||||||
--- a/sm1
|
--- a/sm1
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1 +0,0 @@
|
@@ -1 +0,0 @@
|
||||||
-sm1
|
-sm1
|
||||||
Submodule sm1 0000000...$head6 (new submodule)
|
Submodule sm1 0000000...$head6 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
test_expect_success 'submodule is up to date' "
|
test_expect_success 'submodule is up to date' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked content' "
|
test_expect_success 'submodule contains untracked content' '
|
||||||
echo new > sm1/new-file &&
|
echo new > sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains untracked content
|
Submodule sm1 contains untracked content
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked content (untracked ignored)' "
|
test_expect_success 'submodule contains untracked content (untracked ignored)' '
|
||||||
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked content (dirty ignored)' "
|
test_expect_success 'submodule contains untracked content (dirty ignored)' '
|
||||||
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked content (all ignored)' "
|
test_expect_success 'submodule contains untracked content (all ignored)' '
|
||||||
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked and modifed content' "
|
test_expect_success 'submodule contains untracked and modifed content' '
|
||||||
echo new > sm1/foo6 &&
|
echo new > sm1/foo6 &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains untracked content
|
Submodule sm1 contains untracked content
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' "
|
test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' '
|
||||||
echo new > sm1/foo6 &&
|
echo new > sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
|
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' '
|
||||||
echo new > sm1/foo6 &&
|
echo new > sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
|
test_expect_success 'submodule contains untracked and modifed content (all ignored)' '
|
||||||
echo new > sm1/foo6 &&
|
echo new > sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule contains modifed content' "
|
test_expect_success 'submodule contains modifed content' '
|
||||||
rm -f sm1/new-file &&
|
rm -f sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
(cd sm1; git commit -mchange foo6 >/dev/null) &&
|
(cd sm1; git commit -mchange foo6 >/dev/null) &&
|
||||||
head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
|
head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
|
||||||
test_expect_success 'submodule is modified' "
|
test_expect_success 'submodule is modified' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked content' "
|
test_expect_success 'modified submodule contains untracked content' '
|
||||||
echo new > sm1/new-file &&
|
echo new > sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains untracked content
|
Submodule sm1 contains untracked content
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked content (untracked ignored)' "
|
test_expect_success 'modified submodule contains untracked content (untracked ignored)' '
|
||||||
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked content (dirty ignored)' "
|
test_expect_success 'modified submodule contains untracked content (dirty ignored)' '
|
||||||
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked content (all ignored)' "
|
test_expect_success 'modified submodule contains untracked content (all ignored)' '
|
||||||
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked and modifed content' "
|
test_expect_success 'modified submodule contains untracked and modifed content' '
|
||||||
echo modification >> sm1/foo6 &&
|
echo modification >> sm1/foo6 &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains untracked content
|
Submodule sm1 contains untracked content
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' "
|
test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' '
|
||||||
echo modification >> sm1/foo6 &&
|
echo modification >> sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' "
|
test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' '
|
||||||
echo modification >> sm1/foo6 &&
|
echo modification >> sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
|
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' '
|
||||||
echo modification >> sm1/foo6 &&
|
echo modification >> sm1/foo6 &&
|
||||||
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
||||||
! test -s actual
|
! test -s actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains modifed content' "
|
test_expect_success 'modified submodule contains modifed content' '
|
||||||
rm -f sm1/new-file &&
|
rm -f sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 contains modified content
|
Submodule sm1 contains modified content
|
||||||
Submodule sm1 $head6..$head8:
|
Submodule sm1 $head6..$head8:
|
||||||
> change
|
> change
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
rm -rf sm1
|
rm -rf sm1
|
||||||
test_expect_success 'deleted submodule' "
|
test_expect_success 'deleted submodule' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6...0000000 (submodule deleted)
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_create_repo sm2 &&
|
test_create_repo sm2 &&
|
||||||
head7=$(add_file sm2 foo8 foo9) &&
|
head7=$(add_file sm2 foo8 foo9) &&
|
||||||
git add sm2
|
git add sm2
|
||||||
|
|
||||||
test_expect_success 'multiple submodules' "
|
test_expect_success 'multiple submodules' '
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6...0000000 (submodule deleted)
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
||||||
Submodule sm2 0000000...$head7 (new submodule)
|
Submodule sm2 0000000...$head7 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'path filter' "
|
test_expect_success 'path filter' '
|
||||||
git diff-index -p --submodule=log HEAD sm2 >actual &&
|
git diff-index -p --submodule=log HEAD sm2 >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm2 0000000...$head7 (new submodule)
|
Submodule sm2 0000000...$head7 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
commit_file sm2
|
commit_file sm2
|
||||||
test_expect_success 'given commit' "
|
test_expect_success 'given commit' '
|
||||||
git diff-index -p --submodule=log HEAD^ >actual &&
|
git diff-index -p --submodule=log HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6...0000000 (submodule deleted)
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
||||||
Submodule sm2 0000000...$head7 (new submodule)
|
Submodule sm2 0000000...$head7 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'given commit --submodule' "
|
test_expect_success 'given commit --submodule' '
|
||||||
git diff-index -p --submodule HEAD^ >actual &&
|
git diff-index -p --submodule HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6...0000000 (submodule deleted)
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
||||||
Submodule sm2 0000000...$head7 (new submodule)
|
Submodule sm2 0000000...$head7 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
fullhead7=$(cd sm2; git rev-list --max-count=1 $head7)
|
fullhead7=$(cd sm2; git rev-parse --verify HEAD)
|
||||||
|
|
||||||
test_expect_success 'given commit --submodule=short' "
|
test_expect_success 'given commit --submodule=short' '
|
||||||
git diff-index -p --submodule=short HEAD^ >actual &&
|
git diff-index -p --submodule=short HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/sm1 b/sm1
|
diff --git a/sm1 b/sm1
|
||||||
deleted file mode 160000
|
deleted file mode 160000
|
||||||
index $head6..0000000
|
index $head6..0000000
|
||||||
--- a/sm1
|
--- a/sm1
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1 +0,0 @@
|
@@ -1 +0,0 @@
|
||||||
-Subproject commit $fullhead6
|
-Subproject commit $fullhead6
|
||||||
diff --git a/sm2 b/sm2
|
diff --git a/sm2 b/sm2
|
||||||
new file mode 160000
|
new file mode 160000
|
||||||
index 0000000..$head7
|
index 0000000..$head7
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/sm2
|
+++ b/sm2
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
+Subproject commit $fullhead7
|
+Subproject commit $fullhead7
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
'
|
||||||
|
|
||||||
test_expect_success 'setup .git file for sm2' '
|
test_expect_success 'setup .git file for sm2' '
|
||||||
(cd sm2 &&
|
(cd sm2 &&
|
||||||
@ -494,9 +493,9 @@ test_expect_success 'setup .git file for sm2' '
|
|||||||
test_expect_success 'diff --submodule with .git file' '
|
test_expect_success 'diff --submodule with .git file' '
|
||||||
git diff --submodule HEAD^ >actual &&
|
git diff --submodule HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
Submodule sm1 $head6...0000000 (submodule deleted)
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
||||||
Submodule sm2 0000000...$head7 (new submodule)
|
Submodule sm2 0000000...$head7 (new submodule)
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user