The code base I'm working on has recently moved from ssh key controlled git to https bitbucket.
I use Magit to handle my version control in Emacs.
In the old ssh world I was never challenged for my username or password.
However, now I'm prompted for a password (and username depending how I clone) every time I perform an action on the repo.
Prompted for username and password:
git clone https://bitbucket.foo.com:8443/scm/bar.git
Prompted for password only:
git clone https://[email protected]:8443/scm/bar.git
Pretty standard stuff so far.
To avoid typing in my username and password each time, I've found I can use auth-source which I can point to an encrypted file which I'm only challenged to authenticate once per emacs session - this suits me perfectly:
(setq auth-sources '((:source "~/.blah.authinfo.gpg"))) (setq magit-process-find-password-functions '(magit-process-password-auth-source))
The decrypted format of the auth-sources file is:
machine mymachine login myloginname password mypassword port myport
What I've found is irrespective of how I clone the repo (with or without username) the only way I can get this to work is to concatenate the protocol, username, and port into the "machine" setting:
machine https://[email protected]:8443 password secret
I would expect to be able to make this work using the following, especially if I clone without specifying the username in the URL, but it doesn't match. In fact you are prompted for the git username and then the above rule will match instead - so the supplied git username is added to the machine moniker and is not matched against the login moniker:
machine bitbucket.foo.com:8443 login my.name password secret port https
This is using the example (see "For url-auth authentication...").
A spot of debugging shows how the matching is performed:
(setq auth-source-debug t)
Decrypting /home/blah/.blah.authinfo.gpg...done auth-source-search: found 0 results (max 1) matching (:max 1 :host "https://[email protected]:8443" :require (:host))
Machine is mapped to :host
I am aware of alternative non-emacs specific solutions using git credentials, but I have my reasons for wanting to control my authentication on a per-emacs session basis.
My question - is this a genuine glitch with magit's mapping of Git URLs onto auth-source, or have I set something up incorrectly or misunderstood?