From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Michael J Gruber <git@drmicha.warpmail.net>
Subject: Re: [PATCH] t3703, t4208: add test cases for magic pathspec
Date: Sun, 08 May 2011 10:59:18 -0700 [thread overview]
Message-ID: <7v7ha1t6o9.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1304852906-29272-1-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Sun, 8 May 2011 18:08:26 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> diff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh
> new file mode 100755
> index 0000000..3d8c6b8
> --- /dev/null
> +++ b/t/t3703-add-magic-pathspec.sh
> @@ -0,0 +1,78 @@
> +#!/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_failure 'colon alone magic can only used alone' '
> + test_must_fail git add -n sub/foo : &&
> + test_must_fail git add -n : sub/foo
> +'
I don't care too much about this case (it is a user error), but if you
promise you will turn this expect-failure to expect-success in a follow-up
patch, why not ;-)?
> +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
> +'
Shouldn't
$ git anycmd :
be equivalent to
$ (cd $(git rev-parse --show-cdup)/. && git anycmd)
for any command? I doubt this test is expecting the right outcome.
Shouldn't it result in "Nothing specified, nothing added."?
> +test_expect_success 'add :/' '
> + (cd sub && git add -n :/ >actual) &&
> + test_cmp expected sub/actual
> +'
This one is expecting the right thing.
> +test_expect_success 'add :/non-existent' '
> + (cd sub && test_must_fail git add -n :/non-existent)
> +'
Just being curious. What should the error message say? Can we make it to
say "fatal: pathspec 'non-ex' from root did not match any files"?
> +cat >expected <<EOF
> +fatal: pathspec ':(icase)ha' did not match any files
> +EOF
When writing a literal, make it a habit to quote EOF to reduce mental load
on the reader, like this:
cat >expected <<\EOF
...
EOF
so that the reader does not have to scan for $var in the text to make
sure.
> +test_expect_failure 'show pathspecs exactly what are typed in' '
> + test_cmp expected error
> +'
Will this break under gettext-poison?
> diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh
> new file mode 100755
> index 0000000..b296a74
> --- /dev/null
> +++ b/t/t4208-log-magic-pathspec.sh
> @@ -0,0 +1,40 @@
> +#!/bin/sh
> +
> +test_description='magic pathspec tests using git-log'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup' '
> + test_commit initial &&
> + test_tick &&
> + git commit --allow-empty -m empty &&
> + mkdir sub
> +'
> +
> +test_expect_failure 'git log :/ ambiguous with [ref]:/path' '
> + test_must_fail git log :/ 2>error &&
> + grep ambiguous error
> +'
> +test_expect_failure 'git log :' '
> + git log :
> +'
These two should expect exactly the same error, I think. ':', ':/' or
anything magic will not satisify verify_filename(), and needs a
double-dash before it.
We could improve the disambiguation heuristics so that when we do not have
a '--' on the command line:
- make sure all the earlier ones are refs and they cannot be a path on
the filesystem (otherwise we need a disambiguator "--").
- the first non-ref argument and everything that follows must be either a
':' magic, a string with globbing character, or a path on the
filesystem, and none of them can be a ref.
Do you want to take a stab at it?
next prev parent reply other threads:[~2011-05-08 17:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v7ha1t6o9.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).