Why does git freeze on git-credential-osxkeychain sometimes?
Asked Answered
H

1

4

When I do cd some-repo; git push origin master in my bash terminal, it doesn't ask me for username/password because I guess git has already saved that (it was so long ago that I don't remember the details of how that went down). I'm pushing to a GitHub repo as the remote origin.

So I have a C++ program that does a fork and

execl("/bin/bash", "/bin/bash", "-c", "cd some-repo; git push origin master", (char *)0);

Then waits for the child bash process to finish.

Sometimes it works just fine, but other times (seemingly randomly) it will freeze up. Looking at the running process hierarchy, I see:

MyProgram
  git
    git-remote-http
      git
        git-credential-osxkeychain

If I kill the child-most git-credential-osx process, my program resumes (because the parent-most git command finishes), with not surprising output such as:

error: git-credential-osxkeychain died of signal 15
error: RPC failed; result=7, HTTP code = 0
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

My question: why does git push origin master always seem to work (without asking me for any username password or other stdin) in a bash terminal, but hangs (probably asks for something on stdin) on git-credential-osxkeychain sometimes but not other times when I run it from my C++ program?

I tried looking for man page on git-credential-osxkeychain and couldn't really find anything. Running it only prints Usage: git credential-osxkeychain <get|store|erase> which isn't self-explanatory enough for me. Thank you!

I'm running OS X 10.8.3; git version 1.7.12.4 (Apple Git-37); GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12).

Hound answered 1/4, 2013 at 23:5 Comment(2)
Are you ssh'ing into the box, or running locally? Do you happen to see a window pop-up asking for your login password? Or maybe it's hidden behind a window? The credential helpers are fairly new, so your password may not have been in the keychain just yet. However, you may have to "unlock" the keychain from time to time, so you should see a dialog box pop-up asking about your login credentials.Bryan
I'm running locally. I don't see any pop-up window, and I've tried looking for it this time. It's not showing up. However, that sounds very likely what's causing the issue. I imagine it's supposed to pop-up, but it isn't. However, it's odd that it doesn't happen if I use Terminal.app, only from within my app. Perhaps it has to do with default environmental variables...Hound
B
2

Without much information, my guess is that the hanging depends on whether or not your login keychain is locked at the time. On the Mac, if the login keychain is unlocked, then the query to get your username and password can proceed unhindered. But if the keychain is locked, then then Mac OS X wants to prompt you for your login password to unlock the keychain. I suspect the dialog box is there, just hidden behind something, so you may have missed it. It'll wait for you to type in your password, effectively hanging the process.

There is more information on the gitcredential infrastructure here, and more about the API (including the command line for a helper) here.

Bryan answered 17/4, 2013 at 8:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.