git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 7/8] setup_tree_pathspec(): interpret '^' as negative pathspec
Date: Sat, 11 Sep 2010 11:29:00 -0600	[thread overview]
Message-ID: <AANLkTin_m+zjHND5AwFhkrZM-VEkn70qgCTwpB2B+RA+@mail.gmail.com> (raw)
In-Reply-To: <1283961023-4491-8-git-send-email-pclouds@gmail.com>

2010/9/8 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
> This patch does preparation work for tree exclusion in
> tree_entry_interesting(). '^' has similar meaning to '!' in
> gitexcludes. '!' is not used because bash does not like arguments with
> a leading '!'.
>
> Eventually, "git diff -- foo ^foo/bar" should show differences in foo,
> except foo/bar. If "git diff -- ^foo" is given, then it implies
> everything except foo, which could surprise users that
> "bar" in "git diff -- bar ^foo" has no effect at all.

I really like the work here.  There are just two things that I think
are missing:
  * It doesn't handle files with leading carats in their name
  * It handles some nested include/exclude cases (e.g. dir
^dir/subdir) but not more complicated ones.

You could add these three testcases (on top of your 8/8 patch) to see
what I mean:


test_expect_failure 'diff ^one one/two' '
	printf "file\none/two/file\n" >expected &&
	git diff --name-only HEAD^ HEAD -- ^one one/two >result &&
	test_cmp expected result
'

test_expect_failure 'diff ^funny-filename' '
	touch ^funny-filename &&
	git add ^funny-filename &&
	git commit -m "Add a filename with a leading carat" &&

	git ls-files >expected &&
	git diff --name-only HEAD^^ HEAD -- ^funny-filename >result &&
	test_cmp expected result &&

	echo ^funny-filename >expected &&
	git diff --name-only HEAD^^ HEAD -- ^^funny-filename >result &&
	test_cmp expected result &&

	git ls-files | grep -v funny-filename >expected &&
	git diff --name-only HEAD^^ HEAD -- ^^^funny-filename >result &&
	test_cmp expected result
'

test_expect_failure 'deeper nested exclude/include' '
	touch one/two/zoo &&
	for i in one/file one/zoo one/two/file; do echo 2 >>$i; done &&
	git add one &&
	git commit -m 4 &&

	printf "one/file\none/two/file\none/zoo\n" > expected &&
	git diff --name-only HEAD^ HEAD -- one ^one/two one/two/file >result &&
	test_cmp expected result &&

	printf "one/two/zoo\n" > expected &&
	git diff --name-only HEAD^ HEAD -- ^one one/two ^one/two/file >result &&
	test_cmp expected result
'

Note: In the second test, I used:
 * "^funny" to search for all files EXCEPT "funny"
 * "^^funny" to search for a file named "^funny"
 * "^^^funny" to search for all files EXCEPT "^funny"
I'm not sure if that's really the syntax we want to adopt, but it
should be easy to change if we decide on some other syntax.

  reply	other threads:[~2010-09-11 17:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-08 15:50 [PATCH 0/8] en/object-list-with-pathspec v4 Nguyễn Thái Ngọc Duy
2010-09-08 15:50 ` [PATCH 1/8] diff-no-index: use diff_tree_setup_paths() Nguyễn Thái Ngọc Duy
2010-09-08 15:50 ` [PATCH 2/8] Introduce struct tree_pathspec_list Nguyễn Thái Ngọc Duy
2010-09-08 15:50 ` [PATCH 3/8] tree_entry_interesting(): remove dependency on struct diff_options Nguyễn Thái Ngọc Duy
2010-09-14 15:59   ` Junio C Hamano
2010-09-14 22:33     ` Nguyen Thai Ngoc Duy
2010-09-14 23:20       ` Junio C Hamano
2010-09-08 15:50 ` [PATCH 4/8] tree-walk: move tree_entry_interesting() from tree-diff.c Nguyễn Thái Ngọc Duy
2010-09-08 15:50 ` [PATCH 5/8] Add testcases showing how pathspecs are ignored with rev-list --objects Nguyễn Thái Ngọc Duy
2010-09-14 16:02   ` Junio C Hamano
2010-09-08 15:50 ` [PATCH 6/8] Make rev-list --objects work together with pathspecs Nguyễn Thái Ngọc Duy
2010-09-08 15:50 ` [PATCH 7/8] setup_tree_pathspec(): interpret '^' as negative pathspec Nguyễn Thái Ngọc Duy
2010-09-11 17:29   ` Elijah Newren [this message]
2010-09-13  1:39     ` Nguyen Thai Ngoc Duy
2010-09-14 16:06   ` Junio C Hamano
2010-09-14 22:41     ` Nguyen Thai Ngoc Duy
2010-09-08 15:50 ` [PATCH 8/8] tree_entry_interesting(): support " Nguyễn Thái Ngọc Duy
2010-09-11 17:33   ` Elijah Newren
2010-09-14 16:18   ` Junio C Hamano
2010-09-14 22:46     ` Nguyen Thai Ngoc Duy
2010-09-11 17:19 ` [PATCH 0/8] en/object-list-with-pathspec v4 Elijah Newren

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=AANLkTin_m+zjHND5AwFhkrZM-VEkn70qgCTwpB2B+RA+@mail.gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).