public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "Claus Schneider(Eficode) via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Brandon Williams" <bwilliams.eng@gmail.com>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Claus Schneider" <claus.schneider@eficode.com>,
	"Ben Knoble" <ben.knoble@gmail.com>,
	"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>,
	"Claus Schneider" <claus.schneider@eficode.com>,
	"Claus Schneider(Eficode)" <claus.schneider@eficode.com>
Subject: [PATCH v4 3/5] tests: t2206-add-submodule-ignored: ignore=all and add --force tests
Date: Fri, 06 Feb 2026 13:22:58 +0000	[thread overview]
Message-ID: <d5ea8eb6e0f645fd06316f469a64c22e16a8e281.1770384180.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1987.v4.git.1770384180.gitgitgadget@gmail.com>

From: "Claus Schneider(Eficode)" <claus.schneider@eficode.com>

The tests verify that the submodule behavior is intact and updating the
config with ignore=all also behaves as intended with configuration in
.gitmodules and configuration given on the command line.

The usage of --force is showcased and tested in the test suite.

The test file is added to meson.build for execution.

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
---
 t/meson.build                    |   1 +
 t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)
 create mode 100755 t/t2206-add-submodule-ignored.sh

diff --git a/t/meson.build b/t/meson.build
index a5531df415..a7d3e3e0a2 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -290,6 +290,7 @@ integration_tests = [
   't2203-add-intent.sh',
   't2204-add-ignored.sh',
   't2205-add-worktree-config.sh',
+  't2206-add-submodule-ignored.sh',
   't2300-cd-to-toplevel.sh',
   't2400-worktree-add.sh',
   't2401-worktree-prune.sh',
diff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh
new file mode 100755
index 0000000000..e581e87ab2
--- /dev/null
+++ b/t/t2206-add-submodule-ignored.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+# shellcheck disable=SC2016
+
+# shellcheck disable=SC2034
+test_description='git add respects submodule ignore=all and explicit pathspec'
+
+# This test covers the behavior of "git add", "git status" and "git log" when
+# dealing with submodules that have the ignore=all setting in
+# .gitmodules. It ensures that changes in such submodules are
+# ignored by default, but can be staged with "git add --force".
+
+# shellcheck disable=SC1091
+. ./test-lib.sh
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+base_path=$(pwd -P)
+
+#1
+test_expect_success 'setup: create origin repos'  '
+	cd "${base_path}" &&
+	git config --global protocol.file.allow always &&
+	git init sub &&
+		pwd &&
+		cd sub &&
+		test_commit sub_file1 &&
+		git tag v1.0 &&
+		test_commit sub_file2 &&
+		git tag v2.0 &&
+		test_commit sub_file3 &&
+		git tag v3.0 &&
+	cd "${base_path}" &&
+	git init main &&
+		cd main &&
+		test_commit first &&
+	cd "${base_path}"
+'
+#2
+# add submodule with default config (ignore=none) and
+# check log that is contains a path entry for the submodule 'sub'
+# change the commit in the submodule and check that 'git status' shows it as modified
+test_expect_success 'main: add submodule with default config'  '
+	cd "${base_path}" &&
+	cd main &&
+	git submodule add ../sub &&
+	git commit -m "add submodule" &&
+	git log --oneline --name-only | grep "^sub$" &&
+	git -C sub reset --hard v2.0 &&
+	git status --porcelain | grep "^ M sub$" &&
+	echo
+'
+#3
+# change the submodule config to ignore=all and check that status and log do not show changes
+test_expect_success 'main: submodule config ignore=all'  '
+	cd "${base_path}" &&
+	cd main &&
+	git config -f .gitmodules submodule.sub.ignore all &&
+	GIT_TRACE=1 git add . &&
+	git commit -m "update submodule config sub.ignore all" &&
+	! git status --porcelain | grep "^.*$" &&
+	! git log --oneline --name-only | grep "^sub$" &&
+	echo
+'
+#4
+# change the commit in the submodule and check that 'git status' does not show it as modified
+# but 'git status --ignore-submodules=none' does show it as modified
+test_expect_success 'sub: change to different sha1 and check status in main'  '
+	cd "${base_path}" &&
+	cd main &&
+	git -C sub reset --hard v1.0 &&
+	! git status --porcelain | grep "^ M sub$" &&
+	git status --ignore-submodules=none --porcelain | grep "^ M sub$" &&
+	echo
+'
+
+#5
+# check that normal 'git add' does not stage the change in the submodule
+test_expect_success 'main: check normal add and status'  '
+	cd "${base_path}" &&
+	cd main &&
+	GIT_TRACE=1 git add . &&
+	! git status --porcelain | grep "^ M sub$" &&
+	echo
+'
+
+#6
+# check that 'git add --force .' does not stage the change in the submodule
+# and that 'git status' does not show it as modified
+test_expect_success 'main: check --force add . and status'  '
+	cd "${base_path}" &&
+	cd main &&
+	GIT_TRACE=1 git add --force . &&
+	! git status --porcelain | grep "^M  sub$" &&
+	echo
+'
+
+#7
+# check that 'git add .' does not stage the change in the submodule
+# and that 'git status' does not show it as modified
+test_expect_success 'main: check _add sub_ and status'  '
+	cd "${base_path}" &&
+	cd main &&
+	GIT_TRACE=1 git add sub 2>&1 | grep "Skipping submodule due to ignore=all: sub" &&
+	! git status --porcelain | grep "^M  sub$" &&
+	echo
+'
+
+#8
+# check that 'git add --force sub' does stage the change in the submodule
+# check that 'git add --force ./sub/' does stage the change in the submodule
+# and that 'git status --porcelain' does show it as modified
+# commit it..
+# check that 'git log --ignore-submodules=none' shows the submodule change
+# in the log
+test_expect_success 'main: check force add sub and ./sub/ and status'  '
+	cd "${base_path}" &&
+	cd main &&
+	echo "Adding with --force should work: git add --force sub" &&
+	GIT_TRACE=1 git add --force sub &&
+	git status --porcelain | grep "^M  sub$" &&
+	git restore --staged sub &&
+	! git status --porcelain | grep "^M  sub$" &&
+	echo "Adding with --force should work: git add --force ./sub/" &&
+	GIT_TRACE=1 git add --force ./sub/ &&
+	git status --porcelain | grep "^M  sub$" &&
+	git commit -m "update submodule pointer" &&
+	! git status --porcelain | grep "^ M sub$" &&
+	git log --ignore-submodules=none --name-only --oneline | grep "^sub$" &&
+	echo
+'
+
+test_done
+exit 0
-- 
gitgitgadget


  parent reply	other threads:[~2026-02-06 13:23 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-18 20:07 [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force Claus Schneider via GitGitGadget
2025-10-18 20:07 ` [PATCH 1/5] read-cache: update add_files_to_cache to take param ignored_too(--force) Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 2/5] read-cache: let read-cache respect submodule ignore=all and --force Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 5/5] Documentation: update add --force and submodule ignore=all config Claus Schneider(Eficode) via GitGitGadget
2025-10-19 15:34 ` [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force Phillip Wood
     [not found]   ` <CA+GP4bpu3SUycG35DU5+NSuiqtfYN9-R=7d01EFhexgGh4sRPg@mail.gmail.com>
2025-10-20  7:28     ` Claus Schneider
     [not found]   ` <CA+GP4bqb775U5oBbLZg1dou+THJOjTbFN+2Pq1cBPqq1SgbxHw@mail.gmail.com>
2025-10-24 13:55     ` Phillip Wood
2025-11-13 12:51       ` Claus Schneider
2025-11-13 18:10 ` [PATCH v2 " Claus Schneider via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 1/5] read-cache: update add_files_to_cache take param include_ignored_submodules Claus Schneider(Eficode) via GitGitGadget
2025-11-13 22:07     ` Junio C Hamano
2025-11-13 18:10   ` [PATCH v2 2/5] read-cache: add/read-cache respect submodule ignore=all Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 5/5] Documentation: add --include_ignored_submodules + ignore=all config Claus Schneider(Eficode) via GitGitGadget
2025-11-13 19:58   ` [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force Junio C Hamano
2025-11-14 13:53     ` Claus Schneider
2026-02-05  8:51       ` Claus Schneider
2026-02-05 22:05         ` Junio C Hamano
2026-01-14  7:47   ` [PATCH v3 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used Claus Schneider via GitGitGadget
2026-01-14  7:47     ` [PATCH v3 1/5] read-cache: update add_files_to_cache take param ignored_too Claus Schneider(Eficode) via GitGitGadget
2026-01-14  7:47     ` [PATCH v3 2/5] read-cache: submodule add need --force given ignore=all configuration Claus Schneider(Eficode) via GitGitGadget
2026-01-15 15:42       ` Kristoffer Haugsbakk
2026-01-16 16:07         ` Claus Schneider
2026-01-14  7:47     ` [PATCH v3 3/5] tests: t2206-add-submodule-ignored: ignore=all and add --force tests Claus Schneider(Eficode) via GitGitGadget
2026-01-14  7:47     ` [PATCH v3 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2026-01-14  7:47     ` [PATCH v3 5/5] Documentation: update add --force option + ignore=all config Claus Schneider(Eficode) via GitGitGadget
2026-01-14 17:53       ` Ben Knoble
2026-01-16 15:35         ` Claus Schneider
2026-02-06 13:22     ` [PATCH v4 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used Claus Schneider via GitGitGadget
2026-02-06 13:22       ` [PATCH v4 1/5] read-cache: update add_files_to_cache take param ignored_too Claus Schneider(Eficode) via GitGitGadget
2026-02-09  0:11         ` Junio C Hamano
2026-02-09  0:11         ` Junio C Hamano
2026-02-06 13:22       ` [PATCH v4 2/5] read-cache: submodule add need --force given ignore=all configuration Claus Schneider(Eficode) via GitGitGadget
2026-02-06 13:22       ` Claus Schneider(Eficode) via GitGitGadget [this message]
2026-02-06 13:22       ` [PATCH v4 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2026-02-06 13:23       ` [PATCH v4 5/5] Documentation: update add --force option + ignore=all config Claus Schneider(Eficode) via GitGitGadget
2026-03-04 14:01         ` Kristoffer Haugsbakk
2026-03-10 21:04           ` Claus Schneider
2026-03-10 21:10             ` Claus Schneider
2026-02-20 22:27       ` [PATCH v4 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used Junio C Hamano

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=d5ea8eb6e0f645fd06316f469a64c22e16a8e281.1770384180.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avarab@gmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=bwilliams.eng@gmail.com \
    --cc=claus.schneider@eficode.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=phillip.wood123@gmail.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