On Fri, May 01, 2020 at 11:59:48PM +0000, brian m. carlson wrote: > I think perhaps many folks aren't aware that you can invoke Git with an > arbitrary shell command as "credential.helper", which of course makes > life a lot easier. So if you want to invoke a separate command, it's > really as easy as this: > > git config credential.smtp://smtp.crustytoothpaste.net.helper \ > '!f() { echo username=my-username; echo "password=$(my-password-command)"; }; f' > > So I think that documenting the use of the credential helper is step 1, > because probably most people _do_ want to use that for their passwords, > and then documenting that credential helpers can be arbitrary shell > commands that speak the protocol is step 2, so that people who don't can > figure out a way to do what they want. > > I'll send some patches later which document the latter feature, since I > don't think we mention it anywhere outside of the FAQ. I actually > didn't know about it until Peff mentioned it to me one time. This is documented, but only recently did it make it out of Documentation/technical/ and into gitcredentials(7). I don't mind adding more pointers, though. It's also being discussed in this thread: https://lore.kernel.org/git/63f35287c9ced4d674f938bedd439aefa6c46f41.camel@xxxxxxxxx/ about how deep into the rabbit-hole we want to go in terms of showing a working example. In particular, in your example above I'd consider checking that "$1" is "get" in the function. You also could be using credential.*.username. It's twice as many git-config commands to set up on the command-line, but IMHO the resulting config file is a little easier to read. -Peff