romkatv / gitstatus

Git status for Bash and Zsh prompt
GNU General Public License v3.0
1.68k stars 106 forks source link

Repositories remain locked after changing directory out of them #399

Closed Terrance closed 1 year ago

Terrance commented 1 year ago

I haven't been able to consistently reproduce this, but have noticed on several occasions that after working with temporary checkouts of repositories in a gitstatus-enabled shell, cding out of them and trying to delete them results in Permission denied errors.

This is with a shell inside WSL version 1 (with the repository on a Windows drive) and seems to be down to Windows' file locking (attempting to delete from File Explorer tells me the directory is in use by another application but doesn't know which). Exiting the shell allows me to then delete that repository with either method, and the only remaining process besides the shell itself is gitstatus, so I'm assuming files within .git are being left open for faster status information on the next access?

romkatv commented 1 year ago

I'm assuming files within .git are being left open for faster status information on the next access?

Spot on. The repos are kept open for one hour. You can restart zsh (exec zsh will do) to avoid waiting.

Terrance commented 1 year ago

Can confirm exec is sufficient to clear the lingering file locks, thanks for the tip!