I am trying to use git commands inside my script, and I want git to fail in any case so that I can check for errors my users supplied in their requests.
The current behavior of git is like this:
- the address is not a git repo, it fails.
- user space does not exist, it asks for a username/password
- repo does not exist or is possibly private, it asks for a username/password
- given username/password/token is wrong, it asks for a username/password.
But this is not just a simple "ask for credentials" function executed, but rather git spawns many other processes all with different process IDs, and also for some reason kills the original spawned process without notifying my spawner script. (Node.js' spawn)
At first, I tried using a timeout to kill the main spawned process if it does not write a response to its stdout but since there is no process with that ID anymore, I fail to check further for errors. I had to give up trying to clone a repo unless supplied address can be fetched from a public api.
All my searches ended up on the other side of the coin, "make it to ask for a password". I wonder if I failed to think of correct search terms for my purpose, or if it is just that there is no such way.
Please enlighten me if there is a flag I have missed, or some other way to do the trick.
PS: I hesitated but I have added node.js tag, but this might be a problem in any language that can spawn child processes.