[PATCH 1/2] t3700 (add): add two tests for testing add with submodules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The first test "git add should not go past gitlink boundaries" checks
that paths within a submodule added with 'git submodule add' cannot be
added to the index.  It passes because of treat_gitlink() in
builtin/add.c.

The second test "git add should not go past git repository boundaries"
checks that paths within a git repository in the worktree (not yet
added with 'git submodule add') cannot be added to the index.  It
fails because there is no existing code to check this.

Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 t/t3700-add.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 874b3a6..1ad2331 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -310,4 +310,36 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
 	test_i18ncmp expect.err actual.err
 '
 
+test_expect_success 'git add should not go past gitlink boundaries' '
+	rm -rf submodule_dir &&
+	mkdir submodule_dir &&
+	(
+		cd submodule_dir &&
+		git init &&
+		git config remote.origin.url "quux" &&
+		cat >foo <<-\EOF &&
+		Some content
+		EOF
+		git add foo &&
+		git commit -a -m "Add foo"
+	) &&
+	git submodule add ./submodule_dir &&
+	test_must_fail git add submodule_dir/foo
+'
+
+test_expect_failure 'git add should not go past git repository boundaries' '
+	rm -rf submodule_dir &&
+	mkdir submodule_dir &&
+	(
+		cd submodule_dir &&
+		git init &&
+		cat >foo <<-\EOF &&
+		Some content
+		EOF
+		git add foo &&
+		git commit -a -m "Add foo"
+	) &&
+	test_must_fail git add submodule_dir/foo
+'
+
 test_done
-- 
1.8.2.1.347.gdd82260.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]