gitless
gitless copied to clipboard
error with gl switch in non existant directory
This is the simplest scenario reproducing the error
$ gl init
$ gl branch -c testBranch
$ gl switch testBranch
$ mkdir testDir
$ touch testDir/txt
$ gl switch master
✘ sh: 0: getcwd() failed: No such file or directory
fatal: Unable to read current working directory: Aucun fichier ou dossier de ce type
If I follow the steps in your scenario I get no error. The only way I was able to get a similar error was by opening another terminal and removing the repo before doing gl switch (although if I do that I get a different error message).
Sorry I forgot to add cd testDir after make testDir.
Apparently the directory testDir is deleted by the switch and getcwd() returns an error because the CWD doesn't exist anymore.
I'm not sure ignoring the error would be ok because as a consequence the .git directory can't be found. My git prompt thinks that there is no .git directory which is frightening. A cd in the appropriate directory solves the issue and the .git directory was not affected.
Another potential problem is that the error doesn't show up when the directory doesn't contain a file. This is because empty directories are not deleted and restored when switching branches. In my opinion this is counter intuitive because it doesn't match the general behavior of directories containing files. This problem doesn't occur if the directory contains another directory. So it's really only empty directories that aren't deleted and restored.
To avoid errors in Gitless like the ones above, I have become accustomed to dedicating a single terminal or command prompt in the working directory having the .git directory to execute all my Gitless commands. I open a second console to navigate, build, develop, etc.
Now, I just have to remember to navigate out of the directories on the second console before I do a gl switch to avoid file system errors due to navigating in directories that have since been made non-existent or stale after switching out.
Sincerely, Al