git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/5] git-son: add tests

From
EGEvan Haque via GitGitGadget <gitgitgadget@gmail.com>
Date
May 26, 2026, 16:47 UTC
Message-ID
<4ed8b58566dbe6f56d09c8e98f155cff4a297cfe.1779814052.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2122.git.1779814052.gitgitgadget@gmail.com>
From: Evan Haque <evanhaque1@gmail.com>
Add t5151-son.sh with nine test cases covering:
 - basic child repository creation
 - parent remote configuration in the child
 - .gitignore update in the parent
 - initial commit presence in the child
 - failure when the target directory already exists
 - --branch without --inherit is rejected cleanly
 - no leftover directory on validation failure
 - --inherit fetches parent history

Register the test in t/meson.build so the meson build system discovers and runs it.

Assisted-by: Claude Opus 4.6
Signed-off-by: Evan Haque <evanhaque1@gmail.com>
---
 t/meson.build  |  1 +
 t/t5151-son.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100755 t/t5151-son.sh
diff --git a/t/meson.build b/t/meson.build
index fd955f44ef..523062df66 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -591,6 +591,7 @@ integration_tests = [
   't5004-archive-corner-cases.sh',
   't5100-mailinfo.sh',
   't5150-request-pull.sh',
+  't5151-son.sh',
   't5200-update-server-info.sh',
   't5300-pack-object.sh',
   't5301-sliding-window.sh',
diff --git a/t/t5151-son.sh b/t/t5151-son.sh
new file mode 100755
index 0000000000..826cbbfa66
--- /dev/null
+++ b/t/t5151-son.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+test_description='Test git son command.'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'setup parent repository' '
+	echo "parent content" >file.txt &&
+	git add file.txt &&
+	git commit -m "Initial parent commit"
+'
+
+test_expect_success 'son creates child repository' '
+	git son my-child &&
+	test -d my-child &&
+	test -d my-child/.git
+'
+
+test_expect_success 'son sets parent remote in child' '
+	(
+		cd my-child &&
+		git remote get-url parent
+	)
+'
+
+test_expect_success 'son adds child to parent .gitignore' '
+	grep "my-child/" .gitignore
+'
+
+test_expect_success 'son child has initial commit' '
+	(
+		cd my-child &&
+		test $(git log --oneline | wc -l) -eq 1
+	)
+'
+
+test_expect_success 'son fails if target already exists' '
+	test_must_fail git son my-child
+'
+
+test_expect_success 'son with --branch requires --inherit' '
+	test_must_fail git son --branch main branch-child
+'
+
+test_expect_success 'son with --branch leaves no directory on failure' '
+	! test -e branch-child
+'
+
+test_expect_success 'son with --inherit fetches parent history' '
+	git init --bare "$TRASH_DIRECTORY/parent.git" &&
+	git push "$TRASH_DIRECTORY/parent.git" main &&
+	git remote add origin "file://$TRASH_DIRECTORY/parent.git" &&
+	git son --inherit inherited-child &&
+	(
+		cd inherited-child &&
+		git log --oneline parent/main
+	)
+'
+
+test_done
-- 
gitgitgadget
Previous: Evan Haque via GitGitGadgetNext: Ben Knoble
Message 6 of 9 in “git son: add command to create independent child repositories”
  1. 0/5 git son: add command to create independent child repositoriesEvan Haque via GitGitGadget, May 26, 2026
  2. 1/5 git-son: add command to create independent child repositoriesEvan Haque via GitGitGadget, May 26, 2026
  3. 2/5 git-son: register in Makefile and meson build systemEvan Haque via GitGitGadget, May 26, 2026
  4. 3/5 git-son: add to command list as mainporcelainEvan Haque via GitGitGadget, May 26, 2026
  5. 4/5 git-son: add documentationEvan Haque via GitGitGadget, May 26, 2026
  6. 5/5 git-son: add testsEvan Haque via GitGitGadget, May 26, 2026
  7. Ben KnobleMay 26, 2026
  8. Claus SchneiderMay 29, 2026
  9. Junio C HamanoJun 1, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.