schell / steeloverseer

A file watcher and development tool.
BSD 3-Clause "New" or "Revised" License
128 stars 15 forks source link

Not triggered for `git checkout` #28

Open michalrus opened 6 years ago

michalrus commented 6 years ago

I’m using the latest HEAD, 85d40083ac893bebc3696ab48f223da8af928874.

I’m first modifying Main.hs 3 times in Emacs, and then switch to some other terminal and do git checkout src/ and:

$ cd some-project/
$ sos src/ -p '\.hs$' -e '/\.#' -e '/flycheck_' -c :        Hit Ctrl+C to quit.

Modified: src/Main.hs
[1/1] :
Success ✓

Modified: src/Main.hs
[1/1] :
Success ✓

Modified: src/Main.hs
[1/1] :
Success ✓

# now I’ll do git checkout src/

# nothing happened
^C
schell commented 6 years ago

@michalrus that's interesting - when you do git checkout src are the files in src/ actually changing on disk? If so, it could be eluding FSNotify, which is what we use to monitor file system events.

michalrus commented 6 years ago

Yes, they are. git checkout src/ will revert all changed files in that directory to their last git-committed state.

Here’s a test script which you can run on your machine (it will create and run in a temporary directory (L5):

#!/bin/sh

set -o xtrace

cd "$(mktemp -d)" || exit 1

git init

echo 'some content' >a.txt
cat a.txt

git add .
git commit --no-gpg-sign -m 'Commit 1'

sos . -p '\.txt$' -c : </dev/stdin &
sosPid=$!

echo
sleep 2

echo
echo 'Will modify a.txt manually in 3 seconds…'
sleep 3
echo 'some more content' >>a.txt
md5sum a.txt

echo
sleep 2

echo 'Will `git checkout a.txt` in 3 seconds…'
sleep 3
git checkout a.txt
md5sum a.txt

echo
sleep 2
echo 'Probably `sos` was not triggered by the checkout; killing it.'

kill -INT $sosPid

It’s output on my machine:

michalrus commented 6 years ago

↑ posted https://github.com/haskell-fswatch/hfsnotify/issues/72