TeXStudio 4.0: git commit encounters GIT_DISCOVERY_ACROSS_FILESYSTEM

gitlinuxfedoratexstudio

For the last few years I have successfully used A TeXstudio script on a Fedora Linux system, inspired by https://ritm.knu.ua/general/how-to-use-git-with-texstudio/ that allowed me to commit changes to all the files in the folder of the tex file to a git repository in that folder (with a .gitignore specifying which files not to commit).

I used a Macro with the trigger ?close-file and this script

%SCRIPT
dialog = new UniversalInputDialog()
dialog.setWindowTitle("Git commit all")
dialog.add("Committed within TeXstudio", "Comment", "comment")
if (dialog.exec() != 0) {
    comment = dialog.get("comment")
    buildManager.runCommand("git commit -a -m \"" + comment + "\" > txs:///messages", editor.fileName())
}

Very recently, this stopped working, even though I am not aware I would have changed the underlying git system underneath (though automatic software updates might have changed something).

I get this error message now

Process started: git commit -a -m "test"

fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Process exited with error(s)

However, in the shell, the command git commit -a -m "test" works without problems in the directory in which the tex file is present. I conclude, thus, that the folder is indeed (asigned) a git repo.

When I change the macro element buildManager.runCommand("git commit -a -m \"" + comment + "\" > txs:///messages", editor.fileName()) to
buildManager.runCommand("**pwd;**git commit -a -m \"" + comment + "\" > txs:///messages", editor.fileName()) I get this error.

 results in 'Error: Could not start the command: pwd;git commit -a -m "test"'. 

And, if I specify the pwd at the end, i.e. as buildManager.runCommand("git commit -a -m \"" + comment + "\"; pwd > txs:///messages", editor.fileName()) I get

Process started: git commit -a -m "test"; pwd

fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Process exited with error(s)

So, the key questions are, do I need to rewrite the script so that TeXstudio interacts successfully with the folder and its git repo? How?

Best Answer

Following feedback from the developing github page at https://github.com/texstudio-org/texstudio/issues/1873 I now use buildManager.runCommand(whatever,editor.fileInfo()).

Thus, the Macro with the trigger ?close-file calls this script now

%SCRIPT
dialog = new UniversalInputDialog()
dialog.setWindowTitle("Git commit all")
dialog.add("Committed within TeXstudio", "Comment", "comment")
if (dialog.exec() != 0) {
    comment = dialog.get("comment")
    buildManager.runCommand("git commit -a -m \"" + comment + "\" > txs:///messages", editor.fileInfo())
}
Related Question