@@ -19,11 +19,12 @@ test_expect_success 'setup: create subprojects' '
( cd sub2 && git init && : >Makefile && git add * &&
git commit -q -m "subproject 2" ) &&
git update-index --add sub1 &&
- git add sub2 &&
+ git submodule add ./sub2 &&
git commit -q -m "subprojects added" &&
GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
git branch save HEAD &&
cat >expected <<-\EOF &&
+ :000000 100644 00000... A .gitmodules
:000000 160000 00000... A sub1
:000000 160000 00000... A sub2
EOF
@@ -50,9 +50,19 @@ test_expect_success 'setup' '
'
test_expect_success 'added submodule' '
- git add sm1 &&
+ git submodule add ./sm1 &&
+ gitmodules_hash1=$(git rev-parse --short $(git hash-object .gitmodules)) &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 0000000...$head1 (new submodule)
EOF
test_cmp expected actual
@@ -63,6 +73,15 @@ test_expect_success 'added submodule, set diff.submodule' '
git add sm1 &&
git diff --cached >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 0000000...$head1 (new submodule)
EOF
git config --unset diff.submodule &&
@@ -74,6 +93,15 @@ test_expect_success '--submodule=short overrides diff.submodule' '
git add sm1 &&
git diff --submodule=short --cached >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
diff --git a/sm1 b/sm1
new file mode 160000
index 0000000..$head1
@@ -89,6 +117,15 @@ 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/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
diff --git a/sm1 b/sm1
new file mode 160000
index 0000000..$head1
@@ -105,6 +142,15 @@ test_expect_success 'modified submodule(forward)' '
head2=$(add_file sm1 foo3) &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head1..$head2:
> Add foo3 ($added foo3)
EOF
@@ -154,6 +200,15 @@ test_expect_success 'modified submodule(backward)' '
) &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head2..$head3 (rewind):
< Add foo3 ($added foo3)
< Add foo2 ($added foo2)
@@ -165,6 +220,15 @@ test_expect_success 'modified submodule(backward and forward)' '
head4=$(add_file sm1 foo4 foo5) &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head2...$head4:
> Add foo5 ($added foo5)
> Add foo4 ($added foo4)
@@ -187,6 +251,15 @@ test_expect_success 'setup - change sm1 to a blob' '
test_expect_success 'typechanged submodule(submodule->blob), --cached' '
git diff --submodule=log --cached >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...0000000 (submodule deleted)
diff --git a/sm1 b/sm1
new file mode 100644
@@ -219,6 +292,15 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
git checkout-index sm1 &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...0000000 (submodule deleted)
diff --git a/sm1 b/sm1
new file mode 100644
@@ -238,6 +320,15 @@ test_expect_success 'nonexistent commit' '
fullhead6=$(cd sm1 && git rev-parse --verify HEAD) &&
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..$gitmodules_hash1
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...$head6 (commits not present)
EOF
test_cmp expected actual
@@ -436,12 +527,24 @@ test_expect_success 'deleted submodule' '
test_expect_success 'create second submodule' '
test_create_repo sm2 &&
head7=$(add_file sm2 foo8 foo9) &&
- git add sm2
+ git submodule add ./sm2 &&
+ gitmodules_hash2=$(git rev-parse --short $(git hash-object .gitmodules))
'
test_expect_success 'multiple submodules' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index $gitmodules_hash1..$gitmodules_hash2 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
Submodule sm1 $head6...0000000 (submodule deleted)
Submodule sm2 0000000...$head7 (new submodule)
EOF
@@ -460,6 +563,17 @@ test_expect_success 'given commit' '
commit_file sm2 &&
git diff-index -p --submodule=log HEAD^ >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index $gitmodules_hash1..$gitmodules_hash2 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
Submodule sm1 $head6...0000000 (submodule deleted)
Submodule sm2 0000000...$head7 (new submodule)
EOF
@@ -469,6 +583,17 @@ test_expect_success 'given commit' '
test_expect_success 'given commit --submodule' '
git diff-index -p --submodule HEAD^ >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index $gitmodules_hash1..$gitmodules_hash2 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
Submodule sm1 $head6...0000000 (submodule deleted)
Submodule sm2 0000000...$head7 (new submodule)
EOF
@@ -479,6 +604,17 @@ test_expect_success 'given commit --submodule=short' '
fullhead7=$(cd sm2 && git rev-parse --verify HEAD) &&
git diff-index -p --submodule=short HEAD^ >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index $gitmodules_hash1..$gitmodules_hash2 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
diff --git a/sm1 b/sm1
deleted file mode 160000
index $head6..0000000
@@ -507,6 +643,17 @@ test_expect_success 'setup .git file for sm2' '
test_expect_success 'diff --submodule with .git file' '
git diff --submodule HEAD^ >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index $gitmodules_hash1..$gitmodules_hash2 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
Submodule sm1 $head6...0000000 (submodule deleted)
Submodule sm2 0000000...$head7 (new submodule)
EOF
@@ -525,7 +672,7 @@ test_expect_success 'diff --submodule with objects referenced by alternates' '
(cd super &&
git clone -s ../sub_alt sub &&
git init &&
- git add sub &&
+ git submodule add ./sub &&
git commit -m "sub a"
) &&
(cd sub_alt &&
@@ -61,9 +61,18 @@ test_expect_success 'setup repository' '
'
test_expect_success 'added submodule' '
- git add sm1 &&
+ git submodule add ./sm1 &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 1234567..89abcde
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 0000000...$head1 (new submodule)
diff --git a/sm1/foo1 b/sm1/foo1
new file mode 100644
@@ -88,6 +97,15 @@ test_expect_success 'added submodule, set diff.submodule' '
git add sm1 &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 1234567..89abcde
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 0000000...$head1 (new submodule)
diff --git a/sm1/foo1 b/sm1/foo1
new file mode 100644
@@ -112,6 +130,15 @@ test_expect_success '--submodule=short overrides diff.submodule' '
git add sm1 &&
git diff --submodule=short --cached >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 1234567..89abcde
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
diff --git a/sm1 b/sm1
new file mode 160000
index 0000000..$head1
@@ -127,6 +154,15 @@ 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/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 1234567..89abcde
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
diff --git a/sm1 b/sm1
new file mode 160000
index 0000000..$head1
@@ -143,6 +179,15 @@ test_expect_success 'modified submodule(forward)' '
head2=$(add_file sm1 foo3) &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head1..$head2:
diff --git a/sm1/foo3 b/sm1/foo3
new file mode 100644
@@ -203,6 +248,15 @@ test_expect_success 'modified submodule(backward)' '
) &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head2..$head3 (rewind):
diff --git a/sm1/foo2 b/sm1/foo2
deleted file mode 100644
@@ -226,6 +280,15 @@ test_expect_success 'modified submodule(backward and forward)' '
head4=$(add_file sm1 foo4 foo5) &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head2...$head4:
diff --git a/sm1/foo2 b/sm1/foo2
deleted file mode 100644
@@ -272,6 +335,15 @@ test_expect_success 'setup - change sm1 to a blob' '
test_expect_success 'typechanged submodule(submodule->blob), --cached' '
git diff --submodule=diff --cached >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...0000000 (submodule deleted)
diff --git a/sm1/foo1 b/sm1/foo1
deleted file mode 100644
@@ -346,6 +418,15 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
git checkout-index sm1 &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...0000000 (submodule deleted)
diff --git a/sm1 b/sm1
new file mode 100644
@@ -364,6 +445,15 @@ test_expect_success 'nonexistent commit' '
head6=$(add_file sm1 foo6 foo7) &&
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ new file mode 100644
+ index 0000000..2334463
+ --- /dev/null
+ +++ b/.gitmodules
+ @@ -0,0 +1,3 @@
+ +[submodule "sm1"]
+ + path = sm1
+ + url = ./sm1
Submodule sm1 $head4...$head6 (commits not present)
EOF
diff_cmp expected actual
@@ -655,12 +745,23 @@ test_expect_success 'deleted submodule' '
test_expect_success 'create second submodule' '
test_create_repo sm2 &&
head9=$(add_file sm2 foo8 foo9) &&
- git add sm2
+ git submodule add ./sm2
'
test_expect_success 'multiple submodules' '
git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF &&
+ diff --git a/.gitmodules b/.gitmodules
+ index 2334463..8809a9f 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,3 +1,6 @@
+ [submodule "sm1"]
+ path = sm1
+ url = ./sm1
+ +[submodule "sm2"]
+ + path = sm2
+ + url = ./sm2
Submodule sm1 $head7...0000000 (submodule deleted)
Submodule sm2 0000000...$head9 (new submodule)
diff --git a/sm2/foo8 b/sm2/foo8
@@ -717,11 +818,13 @@ test_expect_success 'given commit' '
git diff-index -p --submodule=diff HEAD^ >actual &&
cat >expected <<-EOF &&
diff --git a/.gitmodules b/.gitmodules
- new file mode 100644
- index 1234567..89abcde
- --- /dev/null
+ index 1234567..89abcde 100644
+ --- a/.gitmodules
+++ b/.gitmodules
- @@ -0,0 +1,3 @@
+ @@ -1,3 +1,3 @@
+ -[submodule "sm1"]
+ - path = sm1
+ - url = ./sm1
+[submodule "sm2"]
+path = sm2
+url = bogus_url
@@ -753,11 +856,13 @@ test_expect_success 'diff --submodule=diff with .git file' '
git diff --submodule=diff HEAD^ >actual &&
cat >expected <<-EOF &&
diff --git a/.gitmodules b/.gitmodules
- new file mode 100644
- index 1234567..89abcde
- --- /dev/null
+ index 1234567..89abcde 100644
+ --- a/.gitmodules
+++ b/.gitmodules
- @@ -0,0 +1,3 @@
+ @@ -1,3 +1,3 @@
+ -[submodule "sm1"]
+ - path = sm1
+ - url = ./sm1
+[submodule "sm2"]
+path = sm2
+url = bogus_url
@@ -31,7 +31,8 @@ sanitize_diff () {
test_expect_success 'setup' '
test_create_repo_with_commit sub &&
echo output > .gitignore &&
- git add sub .gitignore &&
+ git submodule add ./sub &&
+ git add .gitignore &&
git commit -m "Add submodule sub"
'
@@ -243,7 +244,7 @@ test_expect_success 'status -a clean (empty submodule dir)' '
'
cat >status_expect <<\EOF
-AA .gitmodules
+UU .gitmodules
A sub1
EOF
@@ -277,7 +278,10 @@ cat >diff_expect <<\EOF
diff --cc .gitmodules
--- a/.gitmodules
+++ b/.gitmodules
-@@@ -1,3 -1,3 +1,9 @@@
+@@@ -1,6 -1,6 +1,12 @@@
+ [submodule "sub"]
+ path = sub
+ url = ./sub
++<<<<<<< HEAD
+[submodule "sub2"]
+ path = sub2
@@ -293,7 +297,10 @@ cat >diff_submodule_expect <<\EOF
diff --cc .gitmodules
--- a/.gitmodules
+++ b/.gitmodules
-@@@ -1,3 -1,3 +1,9 @@@
+@@@ -1,6 -1,6 +1,12 @@@
+ [submodule "sub"]
+ path = sub
+ url = ./sub
++<<<<<<< HEAD
+[submodule "sub2"]
+ path = sub2