title: Avoid username/password prompt when running git credential fill
body: <p>I'm trying to run the <code>git credential fill</code> command from a Node.js program. I want to use it to check whether there is a stored username/password for a given URL. If there is one, I'm parsing the output (<em>stdout</em>) of the <code>git credential</code> command to get the stored username and password.</p>
  
  <p>If the OS credential helper does not have a stored username/password for the URL, I want the program to terminate silently. Unfortunately, this does not work. When running my program from a shell, the <code>git credential fill</code> command asks for username and password in the terminal:</p>
  
  <pre><code>$ git credential fill
  url=http://foo.foo
  
  Username for 'http://foo.foo': ^C
  </code></pre>
  
  <p>In the above example, I stopped the execution by pressing <em>Ctrl+C</em> since I'm not interested in entering a username/password.</p>
  
  <p>Is there a way to run <code>git credential fill</code> so that it does not ask for a username/password if it does not have one, and simply terminates silently?</p>
  
  <p>When I call the <code>git credential fill</code> from a Node.js program using the <code>child_process.spawn</code> function, the same happens:</p>
  
  <pre><code>var output;
  
  var command = spawn('git', ['credential', 'fill']);
  
  command.stdout.on('data', function (data) {
      output = data;
  });
  
  command.stdout.on('end', function () {
      // callback is a function defined outside that receives the git command's output.
      callback(output);
  });
  
  command.stdin.write('url=http://foo\n\n');
  </code></pre>
  
  <p>When running this from a standard bash shell, the same happens, it asks for username/password again.</p>
  
  <p>When I run the above program from inside the WebStorm IDE using its run mode, the git credential program is not asking for username/password, it simply terminates silently. It looks like WebStorm runs this program in a shell that does not support user input. Is there a way to achieve the same when running in a shell?</p>