Get output when username is asked on msysgit in Python (on windows)
Question: I'm trying to get the output when doing a git fetch, but it's halting asking
for the user name and I'm unable to detect that.

I.e.: In a Python script I'm doing:

    
    
    cmd = 'git fetch origin master'.split()
    import subprocess
    p = subprocess.Popen(cmd, cwd='.',stderr=subprocess.PIPE)
    while p.poll() is None:
        r = p.stderr.read(1)
        print(r)
    

And it just halts without printing anything. If I ran it without piping
stderr, the message asking for the username appears (so, it's writing but
stderr.read does not detect anything).

    
    
    [16:41:45 X:\]python test.py
    Username for 'my.domain.com.br': 
    

I've tried dealing with stderr.fileno() directly, changing the Popen bufsize,
writing to the process.stdin, closing stdin and many different things to no
avail. Anyone knows of a way to get that to work? (my feeling is that msysgit
is just writing asking for the username without flushing or writing a new line
and Python cannot deal with that properly, in which case it might only be
fixed at msysgit? -- although it does appear in the shell if I don't pipe it,
which is odd).

Context: I'm doing a program to help in dealing with multiple repositories at
once (https://github.com/fabioz/mu-repo), so, as it can execute that for lots
of repositories at once, not piping it is not really an option as too many
things appear garbled (things do work if ssh access is specified or the
password is already set through other means, but I'd like to have a way to say
to users that the process is stuck waiting for input instead of just hanging
there -- if there's a way to execute it making sure that git will fail if the
password is asked, that'd suffice too).


Answer: Set up your global config for user name and email. Then git will not prompt
for these.

    
    
    git config --global user.name "Your Name"
    git config --global user.email "your@email.address"
    

