Merge branch 'ss/t7401-modernize'
Test clean-up. * ss/t7401-modernize: t7401: add a NEEDSWORK t7401: change indentation for enhanced readability t7401: change syntax of test_i18ncmp calls for clarity t7401: use 'short' instead of 'verify' and cut in rev-parse calls t7401: modernize stylemaint
commit
3cbff011b0
|
@ -5,8 +5,11 @@
|
||||||
|
|
||||||
test_description='Summary support for submodules
|
test_description='Summary support for submodules
|
||||||
|
|
||||||
This test tries to verify the sanity of summary subcommand of git submodule.
|
This test script tries to verify the sanity of summary subcommand of git submodule.
|
||||||
'
|
'
|
||||||
|
# NEEDSWORK: This test script is old fashioned and may need a big cleanup due to
|
||||||
|
# various reasons, one of them being that there are lots of commands taking place
|
||||||
|
# outside of 'test_expect_success' block, which is no longer in good-style.
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
@ -16,12 +19,12 @@ add_file () {
|
||||||
owd=$(pwd)
|
owd=$(pwd)
|
||||||
cd "$sm"
|
cd "$sm"
|
||||||
for name; do
|
for name; 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"
|
||||||
done >/dev/null
|
done >/dev/null
|
||||||
git rev-parse --verify HEAD | cut -c1-7
|
git rev-parse --short HEAD
|
||||||
cd "$owd"
|
cd "$owd"
|
||||||
}
|
}
|
||||||
commit_file () {
|
commit_file () {
|
||||||
|
@ -38,10 +41,10 @@ test_expect_success 'added submodule' "
|
||||||
git add sm1 &&
|
git add sm1 &&
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 0000000...$head1 (2):
|
* sm1 0000000...$head1 (2):
|
||||||
> Add foo2
|
> Add foo2
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -52,10 +55,10 @@ test_expect_success 'added submodule (subdirectory)' "
|
||||||
git submodule summary >../actual
|
git submodule summary >../actual
|
||||||
) &&
|
) &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* ../sm1 0000000...$head1 (2):
|
* ../sm1 0000000...$head1 (2):
|
||||||
> Add foo2
|
> Add foo2
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -73,10 +76,10 @@ test_expect_success 'added submodule (subdirectory with explicit path)' "
|
||||||
git submodule summary ../sm1 >../actual
|
git submodule summary ../sm1 >../actual
|
||||||
) &&
|
) &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* ../sm1 0000000...$head1 (2):
|
* ../sm1 0000000...$head1 (2):
|
||||||
> Add foo2
|
> Add foo2
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -86,20 +89,20 @@ head2=$(add_file sm1 foo3)
|
||||||
test_expect_success 'modified submodule(forward)' "
|
test_expect_success 'modified submodule(forward)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head1...$head2 (1):
|
* sm1 $head1...$head2 (1):
|
||||||
> Add foo3
|
> Add foo3
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'modified submodule(forward), --files' "
|
test_expect_success 'modified submodule(forward), --files' "
|
||||||
git submodule summary --files >actual &&
|
git submodule summary --files >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head1...$head2 (1):
|
* sm1 $head1...$head2 (1):
|
||||||
> Add foo3
|
> Add foo3
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -110,10 +113,10 @@ test_expect_success 'no ignore=all setting has any effect' "
|
||||||
git config diff.ignoreSubmodules all &&
|
git config diff.ignoreSubmodules all &&
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head1...$head2 (1):
|
* sm1 $head1...$head2 (1):
|
||||||
> Add foo3
|
> Add foo3
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual &&
|
test_cmp expected actual &&
|
||||||
git config --unset diff.ignoreSubmodules &&
|
git config --unset diff.ignoreSubmodules &&
|
||||||
git config --remove-section submodule.sm1 &&
|
git config --remove-section submodule.sm1 &&
|
||||||
|
@ -125,17 +128,17 @@ 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 HEAD
|
||||||
)
|
)
|
||||||
|
|
||||||
test_expect_success 'modified submodule(backward)' "
|
test_expect_success 'modified submodule(backward)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head3 (2):
|
* sm1 $head2...$head3 (2):
|
||||||
< Add foo3
|
< Add foo3
|
||||||
< Add foo2
|
< Add foo2
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -144,25 +147,25 @@ 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 submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head4 (4):
|
* sm1 $head2...$head4 (4):
|
||||||
> 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
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success '--summary-limit' "
|
test_expect_success '--summary-limit' "
|
||||||
git submodule summary -n 3 >actual &&
|
git submodule summary -n 3 >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head4 (4):
|
* sm1 $head2...$head4 (4):
|
||||||
> Add foo5
|
> Add foo5
|
||||||
> Add foo4
|
> Add foo4
|
||||||
< Add foo3
|
< Add foo3
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -177,21 +180,21 @@ mv sm1-bak sm1
|
||||||
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
|
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
|
||||||
git submodule summary --cached >actual &&
|
git submodule summary --cached >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4(submodule)->$head5(blob) (3):
|
* sm1 $head4(submodule)->$head5(blob) (3):
|
||||||
< Add foo5
|
< Add foo5
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'typechanged submodule(submodule->blob), --files' "
|
test_expect_success 'typechanged submodule(submodule->blob), --files' "
|
||||||
git submodule summary --files >actual &&
|
git submodule summary --files >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head5(blob)->$head4(submodule) (3):
|
* sm1 $head5(blob)->$head4(submodule) (3):
|
||||||
> Add foo5
|
> Add foo5
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
rm -rf sm1 &&
|
rm -rf sm1 &&
|
||||||
|
@ -199,10 +202,10 @@ git checkout-index sm1
|
||||||
test_expect_success 'typechanged submodule(submodule->blob)' "
|
test_expect_success 'typechanged submodule(submodule->blob)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4(submodule)->$head5(blob):
|
* sm1 $head4(submodule)->$head5(blob):
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
rm -f sm1 &&
|
rm -f sm1 &&
|
||||||
|
@ -211,21 +214,21 @@ head6=$(add_file sm1 foo6 foo7)
|
||||||
test_expect_success 'nonexistent commit' "
|
test_expect_success 'nonexistent commit' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4...$head6:
|
* sm1 $head4...$head6:
|
||||||
Warn: sm1 doesn't contain commit $head4_full
|
Warn: sm1 doesn't contain commit $head4_full
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file
|
commit_file
|
||||||
test_expect_success 'typechanged submodule(blob->submodule)' "
|
test_expect_success 'typechanged submodule(blob->submodule)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head5(blob)->$head6(submodule) (2):
|
* sm1 $head5(blob)->$head6(submodule) (2):
|
||||||
> Add foo7
|
> Add foo7
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp expected actual
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -234,9 +237,9 @@ rm -rf sm1
|
||||||
test_expect_success 'deleted submodule' "
|
test_expect_success 'deleted submodule' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -249,22 +252,22 @@ test_expect_success 'create second submodule' '
|
||||||
test_expect_success 'multiple submodules' "
|
test_expect_success 'multiple submodules' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'path filter' "
|
test_expect_success 'path filter' "
|
||||||
git submodule summary sm2 >actual &&
|
git submodule summary sm2 >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -272,24 +275,24 @@ commit_file sm2
|
||||||
test_expect_success 'given commit' "
|
test_expect_success 'given commit' "
|
||||||
git submodule summary HEAD^ >actual &&
|
git submodule summary HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success '--for-status' "
|
test_expect_success '--for-status' "
|
||||||
git submodule summary --for-status HEAD^ >actual &&
|
git submodule summary --for-status HEAD^ >actual &&
|
||||||
test_i18ncmp actual - <<EOF
|
test_i18ncmp - actual <<-EOF
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'fail when using --files together with --cached' "
|
test_expect_success 'fail when using --files together with --cached' "
|
||||||
|
|
Loading…
Reference in New Issue