1

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?

9
  • as it says, that isn't a git repository. If git doesn't see its data in .git diectory it goes up a directpry level and looks again until it reaches the root of the filesystem and gives up with the message that you show. So either your file is under git control but something misconfigured or it's not. If you cd there in the shell and type git status, what happens? ie check it works outside the editor first. Er you already did this so you are in "this can't happen" territory, double check that the copy of the file texstudio is seeing really is the same as the one you tested in the shell... Commented Oct 11, 2021 at 8:07
  • 1
    try using pwd;git commit ..... so that it shows you its current directory before the error message Commented Oct 11, 2021 at 8:11
  • git (status and commits) work successfully in the folders. So, indeed the "this can't happen" territory. TexStudio does not complete the operation in any folder! Not just one folder. I used it before on a number of tex repos, the macro ceased working all over. @DavidCarlisle, I have extended the question with more details.
    – ingli
    Commented Oct 11, 2021 at 19:23
  • are you sure texstudio is running git in the right place, eg if the process working directory is not the document directory and you do pdflatex ../some/path/to/file.tex then latex will work but git could easily be run in the wrong place, as I say replace git by pwd so you see where it is running Commented Oct 11, 2021 at 19:26
  • 2
    sorry, all I know about texstudio is that it isn't emacs:-) Commented Oct 12, 2021 at 20:48

1 Answer 1

0

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())
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .