guard/listen — pull request #273 by e2 (2014-11-13 12:29:36+00:00)
Title: abort on filesystem loop

@rymai, @thibaudgg - I think this is pretty drastic, so I wanted some feedback before thinking of releasing this.

### TL;DR With this patch - Listen aborts (!) if you symlink a directory to another directory within the project

#### There are 3 scenarios:
1) *normal symlink* - when there's a symlink do a directory in another "branch", e.g.
foo/bar -> /baz/bar # outside watched dir

2) *duplicate watched dir* - when a symlink points to a directory WITHIN the watched dir

3) Bad, i.e. *filesystem loop* (and e.g. `find -L` also halts on this)
foo/bar/baz -> ../..

#### The patch

This patch makes Listen abort on `3` (obviously), but also aborts on `2`, which I think is ok, because either the user resolves the ambiguity (see below), or complex resolving would have to be implemented in Listen (pointless waste of time).

#### Best solution

The "best" solution is for users to set watchdirs to `Listen` in such a way, that `2` is avoided.

#### Biggest challenge with symlinks:

Intuitively, users "expect" Listen to do a "REVERSE symlink resolution" and ... return ONLY one path/event!

E.g., given the user edits: `project/foo/bar/hello.rb`, and `project/foo` links to `-> project/vendor/baz`, and listen watches `project` then what should Listen report as modified?

a) what the user edited? (`foo/bar/hello.rb`)

b) or what physically changed relative to the watched dir ? (`vendor/baz/bar/hello.rb`)

Of course, option a) is most "user friendly" and "expected", but it gets hairy if you have multiple symlinks pointing to `vendor/baz/bar`.

#### My stance on this

I'm in favor of not letting users watch the same physical directory multiple times (files are ok) because of:
- complexity
- ambiguity
- resources (threads mostly)
- performance

Of course it would be up to the user to make sure there are no loops or symlinks - and I believe that's how it should be, because Listen cannot "lock" the filesystem for itself or find out what symlink was used when a file changed.

#### Semver

At the very least I can release a 3.0 of Listen.

What do you think?