Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-sync-on-inotify can let certain changes slip through #23

Closed
Dieterbe opened this issue Nov 11, 2021 · 9 comments
Closed

git-sync-on-inotify can let certain changes slip through #23

Dieterbe opened this issue Nov 11, 2021 · 9 comments

Comments

@Dieterbe
Copy link

Dieterbe commented Nov 11, 2021

  1. notifywait prints the first file modified (example : touch foo.1 foo.2, $changedFile will be "foo.1") so if you write to multiple files simultaneously, if the first file is in .gitignore, the git-sync will be skipped and the change to the other (non ignored files) will be "forgotten about".
  2. any changes that happen in between two calls of notifywait (e.g. while GIT_SYNC_COMMAND is running, or while the ignore check is running) are unnoticed and "forgotten about"

the first issue can be solved by running inotifywait -m and processing all events - or leaving the gitignore related work up to GIT_SYNC_COMMAND.

the second can be solved by running inotifywait without a timeout, so it catches everything, and concurrently - in another thread - implement the timeout (e.g. with a sleep) to periodically trigger the sync. But I'm not sure how to do this all in bash in a way that we don't concurrently run two syncs (one due to an inotifywait event and one due to a timeout), doing this in something like Go would make more sense... maybe we should just document the shortcomings for the bash version, and defer to another program for more advanced/fewer edge cases. I'm sure they exist but i'll need to search around a bit.

@Dieterbe
Copy link
Author

maybe we should just document the shortcomings for the bash version, and defer to another program for more advanced/fewer edge cases. I'm sure they exist but i'll need to search around a bit.

https://github.com/cortesi/modd seems to work well in my tests, and in particular seems to handle both of the above cases as expected. I use this modd.conf:

** +noignore {
    prep: /home/dieter/scripts/git-sync
}

@simonthum
Copy link
Owner

Hi, nice catch! I guess the shortcomings should be addressed and documented, maybe @IvanMalison can whip something up?

I think most - but not all - cases could be catched by adding e.g. a one second delay before git scans for changes. What do you think?

@simonthum
Copy link
Owner

To close this I propose to move both solutions to a new /contrib directory. If there are any concerns please speak up.

@Dieterbe
Copy link
Author

I don't think a delay will fix this. I recommend documenting the shortcomings until there is a fix. I don't plan to work on this as I switched to modd.

@simonthum
Copy link
Owner

Yes, I'll document the shortcomings and move. Is your modd.conf still valid and are you OK with putting it under contrib?

@simonthum
Copy link
Owner

I pushed the move to contrib/, please have a look.

As an aside, I think git-sync-on-inotify with GIT_SYNC_INTERVAL will be OK and in some cases better. I have documented the state of affairs so users can make an informed choice.

simonthum added a commit that referenced this issue Jan 2, 2022
See github/cortesi/modd

Thanks to @Dieterbe for bringing this up!
@simonthum
Copy link
Owner

@IvanMalison you might also want to have a look!

simonthum added a commit that referenced this issue Jan 2, 2022
See github/cortesi/modd

Thanks to @Dieterbe for bringing this up!
@Dieterbe
Copy link
Author

Dieterbe commented Jan 7, 2022

Is your modd.conf still valid and are you OK with putting it under contrib?

yeah i still use the same config as i shared earlier. works fine for me. cheers!

@simonthum
Copy link
Owner

Thanks for letting me know! BTW I dropped the noignore as it was a bit of a foggy option to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants