From: Calvin Wan <calvinwan@google.com>
To: git@vger.kernel.org
Cc: Josh Steadmon <steadmon@google.com>, Calvin Wan <calvinwan@google.com>
Subject: [RFC PATCH 5/6] tests: use `git submodule add` and fix expected status
Date: Mon, 13 Feb 2023 18:21:33 +0000 [thread overview]
Message-ID: <20230213182134.2173280-6-calvinwan@google.com> (raw)
In-Reply-To: <20230213182134.2173280-1-calvinwan@google.com>
From: Josh Steadmon <steadmon@google.com>
This commit continues the previous work of updating the test suite to
use `git submodule add` to create submodules instead of using `git add`
to include embedded repositories.
In this commit, we update test cases where the expected status output
must change due to the presence of a .gitmodules file. We use the
pre-existing expected output as a template for cases where .gitmodules
has been modified but not committed.
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
t/t4027-diff-submodule.sh | 17 +++--
t/t7508-status.sh | 134 ++++++++++++++++++++++++++++++++------
2 files changed, 128 insertions(+), 23 deletions(-)
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 40164ae07d..2ee9f18b38 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -18,7 +18,8 @@ test_expect_success setup '
test_tick &&
echo frotz >nitfol &&
- git add nitfol sub &&
+ git add nitfol &&
+ git submodule add ./sub &&
git commit -m superproject &&
(
@@ -122,25 +123,30 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
'
test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' '
+ git branch pristine-gitmodules &&
git config diff.ignoreSubmodules dirty &&
git diff HEAD >actual &&
test_must_be_empty actual &&
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sub &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual &&
sed -e "1,/^@@/d" actual >actual.body &&
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual.body &&
git config -f .gitmodules submodule.subname.ignore all &&
git config -f .gitmodules submodule.subname.path sub &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual2 &&
test_must_be_empty actual2 &&
git config -f .gitmodules submodule.subname.ignore untracked &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual3 &&
sed -e "1,/^@@/d" actual3 >actual3.body &&
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual3.body &&
git config -f .gitmodules submodule.subname.ignore dirty &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual4 &&
test_must_be_empty actual4 &&
git config submodule.subname.ignore none &&
@@ -152,7 +158,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)
git config --remove-section submodule.subname &&
git config --remove-section -f .gitmodules submodule.subname &&
git config --unset diff.ignoreSubmodules &&
- rm .gitmodules
+ git reset --hard pristine-gitmodules
'
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
@@ -190,12 +196,15 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.gitmodules]' '
git config --add -f .gitmodules submodule.subname.ignore all &&
git config --add -f .gitmodules submodule.subname.path sub &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual2 &&
test_must_be_empty actual2 &&
git config -f .gitmodules submodule.subname.ignore untracked &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual3 &&
test_must_be_empty actual3 &&
git config -f .gitmodules submodule.subname.ignore dirty &&
+ git commit -m "Update .gitmodules" .gitmodules &&
git diff HEAD >actual4 &&
test_must_be_empty actual4 &&
git config submodule.subname.ignore none &&
@@ -206,7 +215,7 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)
test_cmp expect.body actual.body &&
git config --remove-section submodule.subname &&
git config --remove-section -f .gitmodules submodule.subname &&
- rm .gitmodules
+ git reset --hard pristine-gitmodules
'
test_expect_success 'git diff between submodule commits' '
@@ -243,7 +252,7 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' '
expect_from_to >expect.body $subtip $subprev &&
git config --remove-section submodule.subname &&
git config --remove-section -f .gitmodules submodule.subname &&
- rm .gitmodules
+ git reset --hard pristine-gitmodules
'
test_expect_success 'git diff (empty submodule dir)' '
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 2b7ef6c41a..5808339997 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -892,7 +892,7 @@ test_expect_success 'setup status submodule summary' '
git add foo &&
git commit -m "Add foo"
) &&
- git add sm
+ git submodule add ./sm
'
test_expect_success 'status submodule summary is disabled by default' '
@@ -904,6 +904,7 @@ and have 1 and 2 different commits each, respectively.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
+ new file: .gitmodules
new file: dir2/added
new file: sm
@@ -931,6 +932,7 @@ test_expect_success 'status --untracked-files=all does not show submodule' '
'
cat >expect <<EOF
+A .gitmodules
M dir1/modified
A dir2/added
A sm
@@ -961,6 +963,7 @@ and have 1 and 2 different commits each, respectively.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
+ new file: .gitmodules
new file: dir2/added
new file: sm
@@ -998,6 +1001,7 @@ test_expect_success 'commit with submodule summary ignores status.displayComment
'
cat >expect <<EOF
+A .gitmodules
M dir1/modified
A dir2/added
A sm
@@ -1068,6 +1072,7 @@ and have 2 and 2 different commits each, respectively.
Changes to be committed:
(use "git restore --source=HEAD^1 --staged <file>..." to unstage)
+ new file: .gitmodules
new file: dir2/added
new file: sm
@@ -1134,7 +1139,6 @@ Submodule changes to be committed:
Untracked files:
(use "git add <file>..." to include in what will be committed)
- .gitmodules
dir1/untracked
dir2/modified
dir2/untracked
@@ -1152,8 +1156,37 @@ test_expect_success '.gitmodules ignore=untracked suppresses submodules with unt
test_cmp expect output &&
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
+ cat > expect-modified-gitmodules << EOF &&
+On branch main
+Your branch and '\''upstream'\'' have diverged,
+and have 2 and 2 different commits each, respectively.
+ (use "git pull" to merge the remote branch into yours)
+
+Changes to be committed:
+ (use "git restore --staged <file>..." to unstage)
+ modified: sm
+
+Changes not staged for commit:
+ (use "git add <file>..." to update what will be committed)
+ (use "git restore <file>..." to discard changes in working directory)
+ modified: .gitmodules
+ modified: dir1/modified
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+ > Add bar
+
+Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+ dir1/untracked
+ dir2/modified
+ dir2/untracked
+ untracked
+
+EOF
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1163,7 +1196,7 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt
git config --add submodule.subname.ignore untracked &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config --remove-section -f .gitmodules submodule.subname
'
@@ -1180,7 +1213,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1190,7 +1223,7 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack
git config --add submodule.subname.ignore dirty &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1205,7 +1238,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with modifie
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1215,7 +1248,7 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie
git config --add submodule.subname.ignore dirty &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1245,7 +1278,6 @@ Submodule changes to be committed:
Untracked files:
(use "git add <file>..." to include in what will be committed)
- .gitmodules
dir1/untracked
dir2/modified
dir2/untracked
@@ -1259,8 +1291,39 @@ EOF
test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
+ cat > expect-modified-gitmodules << EOF &&
+On branch main
+Your branch and '\''upstream'\'' have diverged,
+and have 2 and 2 different commits each, respectively.
+ (use "git pull" to merge the remote branch into yours)
+
+Changes to be committed:
+ (use "git restore --staged <file>..." to unstage)
+ modified: sm
+
+Changes not staged for commit:
+ (use "git add <file>..." to update what will be committed)
+ (use "git restore <file>..." to discard changes in working directory)
+ (commit or discard the untracked or modified content in submodules)
+ modified: .gitmodules
+ modified: dir1/modified
+ modified: sm (modified content)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+ > Add bar
+
+Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+ dir1/untracked
+ dir2/modified
+ dir2/untracked
+ untracked
+
+EOF
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1270,7 +1333,7 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi
git config --add submodule.subname.ignore untracked &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1306,7 +1369,6 @@ Submodules changed but not updated:
Untracked files:
(use "git add <file>..." to include in what will be committed)
- .gitmodules
dir1/untracked
dir2/modified
dir2/untracked
@@ -1318,10 +1380,45 @@ EOF
'
test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
+ cat > expect-modified-gitmodules << EOF &&
+On branch main
+Your branch and '\''upstream'\'' have diverged,
+and have 2 and 2 different commits each, respectively.
+ (use "git pull" to merge the remote branch into yours)
+
+Changes to be committed:
+ (use "git restore --staged <file>..." to unstage)
+ modified: sm
+
+Changes not staged for commit:
+ (use "git add <file>..." to update what will be committed)
+ (use "git restore <file>..." to discard changes in working directory)
+ modified: .gitmodules
+ modified: dir1/modified
+ modified: sm (new commits)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+ > Add bar
+
+Submodules changed but not updated:
+
+* sm $new_head...$head2 (1):
+ > 2nd commit
+
+Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+ dir1/untracked
+ dir2/modified
+ dir2/untracked
+ untracked
+
+EOF
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1331,7 +1428,7 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum
git config --add submodule.subname.ignore untracked &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1344,7 +1441,7 @@ test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1354,7 +1451,7 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary
git config --add submodule.subname.ignore dirty &&
git config --add submodule.subname.path sm &&
git status >output &&
- test_cmp expect output &&
+ test_cmp expect-modified-gitmodules output &&
git config --remove-section submodule.subname &&
git config -f .gitmodules --remove-section submodule.subname
'
@@ -1387,7 +1484,6 @@ cat > expect << EOF
;
; Untracked files:
; (use "git add <file>..." to include in what will be committed)
-; .gitmodules
; dir1/untracked
; dir2/modified
; dir2/untracked
@@ -1420,7 +1516,6 @@ Changes not staged for commit:
Untracked files:
(use "git add <file>..." to include in what will be committed)
- .gitmodules
dir1/untracked
dir2/modified
dir2/untracked
@@ -1446,11 +1541,11 @@ Changes to be committed:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
+ modified: .gitmodules
modified: dir1/modified
Untracked files:
(use "git add <file>..." to include in what will be committed)
- .gitmodules
dir1/untracked
dir2/modified
dir2/untracked
@@ -1566,6 +1661,7 @@ Changes to be committed:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
+ modified: .gitmodules
modified: dir1/modified
Untracked files not listed (use -u option to show untracked files)
--
2.39.1.581.gbfd45094c4-goog
next prev parent reply other threads:[~2023-02-13 18:22 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 18:21 [RFC PATCH 0/6] add: block invalid submodules Calvin Wan
2023-02-13 18:21 ` [RFC PATCH 1/6] leak fix: cache_put_path Calvin Wan
2023-02-13 19:23 ` Junio C Hamano
2023-02-14 19:56 ` Calvin Wan
2023-02-14 21:08 ` Junio C Hamano
2023-02-14 21:39 ` Calvin Wan
2023-02-14 21:59 ` Junio C Hamano
2023-02-13 18:21 ` [RFC PATCH 2/6] t4041, t4060: modernize test style Calvin Wan
2023-02-13 19:41 ` Junio C Hamano
2023-02-14 20:22 ` Calvin Wan
2023-02-13 18:21 ` [RFC PATCH 3/6] tests: Use `git submodule add` instead of `git add` Calvin Wan
2023-02-13 18:21 ` [RFC PATCH 4/6] tests: use `git submodule add` and fix expected diffs Calvin Wan
2023-02-13 23:07 ` Junio C Hamano
2023-02-13 23:19 ` Junio C Hamano
2023-02-13 18:21 ` Calvin Wan [this message]
2023-02-13 18:21 ` [RFC PATCH 6/6] add: reject nested repositories Calvin Wan
2023-02-13 20:42 ` Jeff King
2023-02-14 2:17 ` Junio C Hamano
2023-02-14 16:07 ` Jeff King
2023-02-14 16:32 ` Junio C Hamano
2023-02-14 21:45 ` Calvin Wan
2023-02-28 18:52 ` [PATCH v2 0/6] add: block invalid submodules Calvin Wan
2023-02-28 18:56 ` [PATCH v2 1/6] t4041, t4060: modernize test style Calvin Wan
2023-03-06 19:32 ` Glen Choo
2023-03-06 20:40 ` Calvin Wan
2023-02-28 18:56 ` [PATCH v2 2/6] tests: Use `git submodule add` instead of `git add` Calvin Wan
2023-02-28 23:30 ` Junio C Hamano
2023-03-03 0:16 ` Calvin Wan
2023-03-06 21:26 ` Glen Choo
2023-02-28 18:56 ` [PATCH v2 3/6] tests: use `git submodule add` and fix expected diffs Calvin Wan
2023-03-06 23:34 ` Glen Choo
2023-03-06 23:57 ` Junio C Hamano
2023-02-28 18:56 ` [PATCH v2 4/6] tests: use `git submodule add` and fix expected status Calvin Wan
2023-03-07 0:15 ` Glen Choo
2023-02-28 18:56 ` [PATCH v2 5/6] tests: remove duplicate .gitmodules path Calvin Wan
2023-02-28 23:35 ` Junio C Hamano
2023-03-02 23:09 ` Calvin Wan
2023-03-07 0:51 ` Glen Choo
2023-02-28 18:56 ` [PATCH v2 6/6] add: reject nested repositories Calvin Wan
2023-03-07 2:04 ` Glen Choo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230213182134.2173280-6-calvinwan@google.com \
--to=calvinwan@google.com \
--cc=git@vger.kernel.org \
--cc=steadmon@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).