{"thread":{"id":"23847","subject":"temporarily unsetting sendemail.smtpuser","startedAt":"2010-05-19T22:54:02Z","lastAt":"2010-05-20T08:23:11Z","messageCount":2,"participants":["Eric Blake","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"141930","messageId":"4BF46C0A.9070000@redhat.com","threadId":"23847","inReplyTo":null,"subject":"temporarily unsetting sendemail.smtpuser","fromName":"Eric Blake","fromEmail":"eblake@redhat.com","sentAt":"2010-05-19T22:54:02Z","receivedAt":"2010-05-19T22:54:02Z","isPatch":false,"sender":{"key":"eblake@redhat.com","avatar":"https://avatars.githubusercontent.com/u/32933908?v=4"},"body":"I have a setup where I normally send patches through my ISP, which\nrequires authentication, so I have sendemail.smtpuser=me and\nsendemail.smtpserverport=587 set in my ~/.gitconfig (among others).  But\nfor one project I work on, I am required to send patches through an\nalternate SMTP server that does not require authentication.\n\nAt first, I thought it would be a simple matter to use git config to\ncreate an alias, where the explicit command line requests would override\nthe global ~/.gitconfig settings:\n\n[alias]\n\tsubmit = send-email --smtp-user= --smtp-server=alternate \\\n\t\t--smtp-server-port=25\n\nBut that fails with:\n\n$ git submit -1\nfatal: unrecognized argument: --smtp-user=\nformat-patch -o /tmp/JgTFO8Rq3v -1 --smtp-user=: command returned error: 128\n\nIn other words, git-send-email didn't recognize the empty --smtp-user=\ncommand as an override request, and instead passed it on to\ngit-format-patch which croaks.\n\nSo I ended up creating this hairy alias instead:\n\n[alias]\n\tsubmit = \"!sh -c 'git config --global --unset sendemail.smtpuser; git\nsend-email --smtp-server=alternate --smtp-server-port=25 \\\"$@\\\"; st=$?;\ngit config --global sendemail.smtpuser me; (exit $st)' sh\"\n\nI suppose I could have used a shell function for fewer forks:\n\n[alias]\n\tsubmit = \"!doit() { git config --global --unset sendemail.smtpuser; git\nsend-email --smtp-server=alternate --smtp-server-port=25 \\\"$@\\\"; st=$?;\ngit config --global sendemail.smtpuser me; return $st; }; doit\"\n\nBut both of those are rather unappealing.  Is there a better approach to\naccomplishing what I wanted?\n\n-- \nEric Blake   eblake@redhat.com    +1-801-349-2682\nLibvirt virtualization library http://libvirt.org\n\n"},{"id":"141937","messageId":"AANLkTilhkDWkGpbkMAbYtgHNI49gAGzi1oYLeE-sdsTE@mail.gmail.com","threadId":"23847","inReplyTo":"4BF46C0A.9070000@redhat.com","subject":"Re: temporarily unsetting sendemail.smtpuser","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-05-20T08:23:11Z","receivedAt":"2010-05-20T08:23:11Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, May 19, 2010 at 22:54, Eric Blake <eblake@redhat.com> wrote:\n> But both of those are rather unappealing.  Is there a better approach to\n> accomplishing what I wanted?\n\n--no-smtp-user ?\n"}]}