Re: [PATCH 7/8] setup_tree_pathspec(): interpret '^' as negative pathspec
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Sep 13, 2010, 01:39 UTC
- Message-ID
- <AANLkTikKtu9Xp1kvHwCzMoPRubLb0VFKTzbgCvF6Sfxf@mail.gmail.com>
- In-Reply-To
- <AANLkTin_m+zjHND5AwFhkrZM-VEkn70qgCTwpB2B+RA+@mail.gmail.com>
2010/9/12 Elijah Newren <newren@gmail.com>:
Show 16 quoted lines
> 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.
Yeah. I originally needed it to compare trees outside narrow area (i.e. negating all pathspecs). But I would need a more robust implementation soon when I implement tree widening.
Show 6 quoted lines
> 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.
Another way is always treat the leading ^ as negative pathspec. If you have file "^foo", specify it with ./^foo. There's still problem with top level entries this way.
-- Duy