Git development
 help / color / mirror / Atom feed
From: "Evan Haque via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Evan Haque <evanhaque1@gmail.com>, Evan Haque <evanhaque1@gmail.com>
Subject: [PATCH 5/5] git-son: add tests
Date: Tue, 26 May 2026 16:47:31 +0000	[thread overview]
Message-ID: <4ed8b58566dbe6f56d09c8e98f155cff4a297cfe.1779814052.git.gitgitgadget@gmail.com> (raw)
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

  parent reply	other threads:[~2026-05-26 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 16:47 [PATCH 0/5] git son: add command to create independent child repositories Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 1/5] git-son: " Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 2/5] git-son: register in Makefile and meson build system Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 3/5] git-son: add to command list as mainporcelain Evan Haque via GitGitGadget
2026-05-26 16:47 ` [PATCH 4/5] git-son: add documentation Evan Haque via GitGitGadget
2026-05-26 16:47 ` Evan Haque via GitGitGadget [this message]
2026-05-26 21:27 ` [PATCH 0/5] git son: add command to create independent child repositories Ben Knoble

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=4ed8b58566dbe6f56d09c8e98f155cff4a297cfe.1779814052.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=evanhaque1@gmail.com \
    --cc=git@vger.kernel.org \
    /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