git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t3703: add test cases for pathspec magic
@ 2011-05-07 10:35 Nguyễn Thái Ngọc Duy
  2011-05-07 18:56 ` Junio C Hamano
  2011-05-08 11:08 ` [PATCH] t3703, t4208: add test cases for magic pathspec Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-05-07 10:35 UTC (permalink / raw)
  To: git, Junio C Hamano, Jeff King, Michael J Gruber
  Cc: Nguyễn Thái Ngọc Duy

That was the intention, but it raises a question: what do we do if a
file happens to have the same name with the given magic pathspec, as
in the last two tests? People can fall into these cases with
"git add *" or something like that.

I'm tempted to reuse "--" the second time to say "no more magic from
here". But there may be better way to deal with it.

Also, long magic must be quoted or at least bash will complain. Is
there any other syntax option that can be used directly without quoting?
---
 t/t3703-add-magic-pathspec.sh |   68 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100755 t/t3703-add-magic-pathspec.sh

diff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh
new file mode 100755
index 0000000..76108ae
--- /dev/null
+++ b/t/t3703-add-magic-pathspec.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+test_description='magic pathspec tests using git-add'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	mkdir sub anothersub &&
+	: >sub/foo &&
+	: >anothersub/foo
+'
+
+test_expect_success 'colon alone magic can only used alone' '
+	test_must_fail git add -n sub/foo : &&
+	test_must_fail git add -n : sub/foo
+'
+
+cat >expected <<EOF
+add 'anothersub/foo'
+add 'expected'
+add 'sub/actual'
+add 'sub/foo'
+EOF
+
+test_expect_success 'add :' '
+	(cd sub && git add -n : >actual) &&
+	test_cmp expected sub/actual
+'
+
+test_expect_success 'add :/' '
+	(cd sub && git add -n :/ >actual) &&
+	test_cmp expected sub/actual
+'
+
+cat >expected <<EOF
+add 'anothersub/foo'
+EOF
+
+test_expect_success 'add :/anothersub' '
+	(cd sub && git add -n :/anothersub >actual) &&
+	test_cmp expected sub/actual
+'
+
+test_expect_success 'add :/non-existent' '
+	(cd sub && test_must_fail git add -n :/non-existent)
+'
+
+cat >expected <<EOF
+add 'sub/foo'
+EOF
+
+test_expect_success 'add :(icase)foo' '
+	(cd sub && git add -n ":(icase)FoO" >actual) &&
+	test_cmp expected sub/actual
+'
+
+test_expect_success 'a file with the same (long) magic name exists' '
+	: >":(case)ha" &&
+	git add -n ":(icase)ha"
+'
+
+test_expect_success 'a file with the same (short) magic name exists' '
+	mkdir ":" &&
+	: >":/bar" &&
+	git add -n :/bar
+'
+
+test_done
-- 
1.7.4.74.g639db

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2011-05-29 20:36 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-07 10:35 [PATCH] t3703: add test cases for pathspec magic Nguyễn Thái Ngọc Duy
2011-05-07 18:56 ` Junio C Hamano
2011-05-08  9:59   ` Nguyen Thai Ngoc Duy
2011-05-08 11:08 ` [PATCH] t3703, t4208: add test cases for magic pathspec Nguyễn Thái Ngọc Duy
2011-05-08 17:59   ` Junio C Hamano
2011-05-09 12:33     ` Nguyen Thai Ngoc Duy
2011-05-09 16:18       ` Junio C Hamano
2011-05-09 22:06       ` Junio C Hamano
2011-05-10  5:51   ` [PATCH 0/9] magic pathspec updates Junio C Hamano
2011-05-10  5:51     ` [PATCH 1/9] grep: use get_pathspec() correctly Junio C Hamano
2011-05-10  5:51     ` [PATCH 2/9] get_pathspec(): an empty ':' pathspec should stand alone Junio C Hamano
2011-05-10  5:51     ` [PATCH 3/9] count_pathspec(): return number of elements in pathspec Junio C Hamano
2011-05-10 13:29       ` Nguyen Thai Ngoc Duy
2011-05-10  5:51     ` [PATCH 4/9] add ":" is a pathspec that is too wide Junio C Hamano
2011-05-10  5:51     ` [PATCH 5/9] git rm ":" is like specifying nothing Junio C Hamano
2011-05-10  5:51     ` [PATCH 6/9] clean " Junio C Hamano
2011-05-10 15:14       ` Thiago Farina
2011-05-10  5:51     ` [PATCH 7/9] mv ":" ":" is like moving nothing from nowhere to nowhere Junio C Hamano
2011-05-10 13:30       ` Nguyen Thai Ngoc Duy
2011-05-10  5:51     ` [PATCH 8/9] checkout ":" is not giving any pathspec Junio C Hamano
2011-05-10  5:51     ` [PATCH 9/9] t3703, t4208: add test cases for magic pathspec Junio C Hamano
2011-05-12  8:21       ` [PATCH jc/magic-pathspec] t3703: Skip tests using directory name ":" on Windows Johannes Sixt
2011-05-29 18:29       ` [PATCH 9/9] t3703, t4208: add test cases for magic pathspec Ævar Arnfjörð Bjarmason
2011-05-29 20:31         ` Junio C Hamano
2011-05-29 20:36           ` Ævar Arnfjörð Bjarmason
2011-05-10 13:47     ` [PATCH 0/9] magic pathspec updates Nguyen Thai Ngoc Duy
2011-05-10 17:07       ` Junio C Hamano
2011-05-11 12:11         ` Nguyen Thai Ngoc Duy

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).