Skip to content

Commit c2d703e

Browse files
committed
update tests with explicit scenary around ignore=all and using --ignore-submodules option on log, status
1 parent 6657438 commit c2d703e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

t/t2206-add-submodule-ignored.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
test_description='git add respects submodule ignore=all and explicit pathspec'
44

5+
# This test covers the behavior of "git add", "git status" and "git log" when
6+
# dealing with submodules that have the ignore=all setting in
7+
# .gitmodules. It ensures that changes in such submodules are
8+
# ignored by default, but can be staged with "git add --force".
9+
510
. ./test-lib.sh
611

712
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
@@ -20,26 +25,38 @@ test_expect_success 'setup: create origin repos' '
2025
git tag v1.0 &&
2126
test_commit sub_file2 &&
2227
git tag v2.0 &&
28+
test_commit sub_file3 &&
29+
git tag v3.0 &&
2330
cd "${base_path}" &&
2431
git init main &&
2532
cd main &&
2633
test_commit first &&
2734
cd "${base_path}"
2835
'
2936
#2
30-
test_expect_success 'main: add submodule and config ignore=all' '
37+
test_expect_success 'main: add submodule with default config' '
3138
cd "${base_path}" &&
3239
cd main &&
3340
git submodule add ../sub &&
3441
git commit -m "add submodule" &&
42+
git log --oneline --name-only | grep "^sub$" &&
43+
git -C sub reset --hard v2.0 &&
44+
git status --porcelain | grep "^ M sub$" &&
45+
echo
46+
'
47+
48+
#3
49+
test_expect_success 'main: submodule config ignore=all' '
50+
cd "${base_path}" &&
51+
cd main &&
3552
git config -f .gitmodules submodule.sub.ignore all &&
3653
git add . &&
3754
git commit -m "update submodule config sub.ignore all" &&
3855
! git status --porcelain | grep "^.*$" &&
56+
! git log --oneline --name-only | grep "^sub$" &&
3957
echo
4058
'
41-
42-
#3
59+
#4
4360
test_expect_success 'sub: change to different sha1 and check status in main' '
4461
cd "${base_path}" &&
4562
cd main &&
@@ -49,7 +66,7 @@ test_expect_success 'sub: change to different sha1 and check status in main' '
4966
echo
5067
'
5168

52-
#4
69+
#5
5370
test_expect_success 'main: check normal add and status' '
5471
cd "${base_path}" &&
5572
cd main &&
@@ -58,7 +75,7 @@ test_expect_success 'main: check normal add and status' '
5875
echo
5976
'
6077

61-
#5
78+
#6
6279
test_expect_success 'main: check force add and status' '
6380
cd "${base_path}" &&
6481
cd main &&
@@ -71,3 +88,4 @@ test_expect_success 'main: check force add and status' '
7188
'
7289
test_done
7390
exit 0
91+

0 commit comments

Comments
 (0)