2009-10-23 11:25:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
|
2013-06-26 10:19:49 +00:00
|
|
|
# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
|
2009-10-23 11:25:33 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Support for verbose submodule differences in git diff
|
|
|
|
|
|
|
|
This test tries to verify the sanity of the --submodule option of git diff.
|
|
|
|
'
|
|
|
|
|
2020-11-18 23:44:27 +00:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2009-10-23 11:25:33 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
2014-05-21 13:20:04 +00:00
|
|
|
# Tested non-UTF-8 encoding
|
|
|
|
test_encoding="ISO8859-1"
|
|
|
|
|
2013-06-26 10:19:49 +00:00
|
|
|
# String "added" in German (translated with Google Translate), encoded in UTF-8,
|
|
|
|
# used in sample commit log messages in add_file() function below.
|
|
|
|
added=$(printf "hinzugef\303\274gt")
|
2009-10-23 11:25:33 +00:00
|
|
|
add_file () {
|
2012-11-30 11:37:35 +00:00
|
|
|
(
|
|
|
|
cd "$1" &&
|
|
|
|
shift &&
|
|
|
|
for name
|
|
|
|
do
|
|
|
|
echo "$name" >"$name" &&
|
|
|
|
git add "$name" &&
|
|
|
|
test_tick &&
|
2013-09-02 14:44:54 +00:00
|
|
|
# "git commit -m" would break MinGW, as Windows refuse to pass
|
|
|
|
# $test_encoding encoded parameter to git.
|
|
|
|
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
|
|
|
|
git -c "i18n.commitEncoding=$test_encoding" commit -F -
|
2012-11-30 11:37:35 +00:00
|
|
|
done >/dev/null &&
|
|
|
|
git rev-parse --short --verify HEAD
|
|
|
|
)
|
2009-10-23 11:25:33 +00: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 11:37:34 +00:00
|
|
|
fullhead1=$(cd sm1; git rev-parse --verify HEAD)
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'added submodule' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git add sm1 &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 0000000...$head1 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'added submodule, set diff.submodule' '
|
2012-11-13 15:42:45 +00:00
|
|
|
git config diff.submodule log &&
|
|
|
|
git add sm1 &&
|
|
|
|
git diff --cached >actual &&
|
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 0000000...$head1 (new submodule)
|
|
|
|
EOF
|
2012-11-13 15:42:45 +00:00
|
|
|
git config --unset diff.submodule &&
|
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2012-11-13 15:42:45 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success '--submodule=short overrides diff.submodule' '
|
2012-11-13 15:42:45 +00:00
|
|
|
test_config diff.submodule log &&
|
|
|
|
git add sm1 &&
|
|
|
|
git diff --submodule=short --cached >actual &&
|
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 15:42:45 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2012-11-13 15:42:45 +00:00
|
|
|
|
2012-11-13 15:42:46 +00: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 13:54:28 +00:00
|
|
|
index 0000000..$head1
|
2012-11-13 15:42:46 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/sm1
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Subproject commit $fullhead1
|
|
|
|
EOF
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2009-10-23 11:25:33 +00:00
|
|
|
commit_file sm1 &&
|
|
|
|
head2=$(add_file sm1 foo3)
|
|
|
|
|
2013-06-26 10:19:50 +00:00
|
|
|
test_expect_success 'modified submodule(forward)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head1..$head2:
|
2013-06-26 10:19:49 +00:00
|
|
|
> Add foo3 ($added foo3)
|
2012-11-30 11:37:36 +00:00
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2013-06-26 10:19:50 +00:00
|
|
|
test_expect_success 'modified submodule(forward)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff --submodule=log >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head1..$head2:
|
2013-06-26 10:19:49 +00:00
|
|
|
> Add foo3 ($added foo3)
|
2012-11-30 11:37:36 +00:00
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2013-06-26 10:19:50 +00:00
|
|
|
test_expect_success 'modified submodule(forward) --submodule' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff --submodule >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head1..$head2:
|
2013-06-26 10:19:49 +00:00
|
|
|
> Add foo3 ($added foo3)
|
2012-11-30 11:37:36 +00:00
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:34 +00:00
|
|
|
fullhead2=$(cd sm1; git rev-parse --verify HEAD)
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'modified submodule(forward) --submodule=short' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff --submodule=short >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
commit_file sm1 &&
|
2010-09-07 01:42:54 +00:00
|
|
|
head3=$(
|
|
|
|
cd sm1 &&
|
|
|
|
git reset --hard HEAD~2 >/dev/null &&
|
2012-11-30 11:37:34 +00:00
|
|
|
git rev-parse --short --verify HEAD
|
2010-09-06 18:39:54 +00:00
|
|
|
)
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2013-06-26 10:19:50 +00:00
|
|
|
test_expect_success 'modified submodule(backward)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head2..$head3 (rewind):
|
2013-06-26 10:19:49 +00:00
|
|
|
< Add foo3 ($added foo3)
|
|
|
|
< Add foo2 ($added foo2)
|
2012-11-30 11:37:36 +00:00
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
head4=$(add_file sm1 foo4 foo5)
|
2013-06-26 10:19:50 +00:00
|
|
|
test_expect_success 'modified submodule(backward and forward)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head2...$head4:
|
2013-06-26 10:19:49 +00:00
|
|
|
> Add foo5 ($added foo5)
|
|
|
|
> Add foo4 ($added foo4)
|
|
|
|
< Add foo3 ($added foo3)
|
|
|
|
< Add foo2 ($added foo2)
|
2012-11-30 11:37:36 +00:00
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00: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 11:37:36 +00:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob), --cached' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff --submodule=log --cached >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff --submodule=log >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
rm -rf sm1 &&
|
|
|
|
git checkout-index sm1
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'typechanged submodule(submodule->blob)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
rm -f sm1 &&
|
|
|
|
test_create_repo sm1 &&
|
|
|
|
head6=$(add_file sm1 foo6 foo7)
|
2012-11-30 11:37:34 +00:00
|
|
|
fullhead6=$(cd sm1; git rev-parse --verify HEAD)
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'nonexistent commit' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head4...$head6 (commits not present)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
commit_file
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'typechanged submodule(blob->submodule)' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
commit_file sm1 &&
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule is up to date' '
|
2010-01-24 14:09:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule contains untracked content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
echo new > sm1/new-file &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule contains untracked content (untracked ignored)' '
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule contains untracked content (dirty ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule contains untracked content (all ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'submodule contains untracked and modified content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
echo new > sm1/foo6 &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo new > sm1/foo6 &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'submodule contains untracked and modified content (dirty ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'submodule contains untracked and modified content (all ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo new > sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'submodule contains modified content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
rm -f sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
|
|
|
(cd sm1; git commit -mchange foo6 >/dev/null) &&
|
2012-11-30 11:37:34 +00:00
|
|
|
head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'submodule is modified' '
|
2010-01-24 14:09:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
echo new > sm1/new-file &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked content (untracked ignored)' '
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked content (dirty ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked content (all ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked and modified content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
echo modification >> sm1/foo6 &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains untracked content
|
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo modification >> sm1/foo6 &&
|
2020-11-10 08:39:00 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked and modified content (dirty ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'modified submodule contains untracked and modified content (all ignored)' '
|
2010-06-08 16:31:51 +00:00
|
|
|
echo modification >> sm1/foo6 &&
|
|
|
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
2018-08-19 21:57:22 +00:00
|
|
|
test_must_be_empty actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-06-08 16:31:51 +00:00
|
|
|
|
2019-11-05 17:07:25 +00:00
|
|
|
test_expect_success 'modified submodule contains modified content' '
|
2010-01-24 14:09:00 +00:00
|
|
|
rm -f sm1/new-file &&
|
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 contains modified content
|
|
|
|
Submodule sm1 $head6..$head8:
|
|
|
|
> change
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2010-01-24 14:09:00 +00:00
|
|
|
|
2009-10-23 11:25:33 +00:00
|
|
|
rm -rf sm1
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'deleted submodule' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2017-06-14 10:58:25 +00:00
|
|
|
test_expect_success 'create second submodule' '
|
|
|
|
test_create_repo sm2 &&
|
|
|
|
head7=$(add_file sm2 foo8 foo9) &&
|
|
|
|
git add sm2
|
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'multiple submodules' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'path filter' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD sm2 >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
|
|
|
commit_file sm2
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'given commit' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=log HEAD^ >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'given commit --submodule' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule HEAD^ >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2012-11-30 11:37:36 +00:00
|
|
|
'
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:34 +00:00
|
|
|
fullhead7=$(cd sm2; git rev-parse --verify HEAD)
|
2009-10-23 11:25:33 +00:00
|
|
|
|
2012-11-30 11:37:36 +00:00
|
|
|
test_expect_success 'given commit --submodule=short' '
|
2009-10-23 11:25:33 +00:00
|
|
|
git diff-index -p --submodule=short HEAD^ >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00: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 11:25:33 +00:00
|
|
|
|
2010-04-10 17:01:12 +00:00
|
|
|
test_expect_success 'setup .git file for sm2' '
|
|
|
|
(cd sm2 &&
|
|
|
|
REAL="$(pwd)/../.real" &&
|
2018-07-02 00:24:00 +00:00
|
|
|
mv .git "$REAL" &&
|
2010-04-10 17:01:12 +00:00
|
|
|
echo "gitdir: $REAL" >.git)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff --submodule with .git file' '
|
|
|
|
git diff --submodule HEAD^ >actual &&
|
2010-11-14 14:44:16 +00:00
|
|
|
cat >expected <<-EOF &&
|
2012-11-30 11:37:36 +00:00
|
|
|
Submodule sm1 $head6...0000000 (submodule deleted)
|
|
|
|
Submodule sm2 0000000...$head7 (new submodule)
|
|
|
|
EOF
|
2010-11-14 14:44:16 +00:00
|
|
|
test_cmp expected actual
|
2010-04-10 17:01:12 +00:00
|
|
|
'
|
|
|
|
|
2012-05-14 16:24:45 +00: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 &&
|
2018-07-02 00:24:00 +00:00
|
|
|
sha1_before=$(git rev-parse --short HEAD) &&
|
2012-05-14 16:24:45 +00:00
|
|
|
echo b >b &&
|
|
|
|
git add b &&
|
2015-03-20 10:07:15 +00:00
|
|
|
git commit -m b &&
|
|
|
|
sha1_after=$(git rev-parse --short HEAD) &&
|
|
|
|
{
|
|
|
|
echo "Submodule sub $sha1_before..$sha1_after:" &&
|
|
|
|
echo " > b"
|
|
|
|
} >../expected
|
2012-05-14 16:24:45 +00:00
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd sub &&
|
|
|
|
git fetch &&
|
2020-11-18 23:44:27 +00:00
|
|
|
git checkout origin/main
|
2012-05-14 16:24:45 +00:00
|
|
|
) &&
|
|
|
|
git diff --submodule > ../actual
|
2015-03-20 10:06:44 +00:00
|
|
|
) &&
|
2012-05-14 16:24:45 +00:00
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2009-10-23 11:25:33 +00:00
|
|
|
test_done
|