git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Olaf Hering <olaf@aepfle.de>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: How to undo previously set configuration?
Date: Thu, 05 Apr 2018 10:42:15 +0200	[thread overview]
Message-ID: <874lkq11ug.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20180405092358.569e0315.olaf@aepfle.de>


On Thu, Apr 05 2018, Olaf Hering wrote:

[Changed subject]

> My ~/.gitconfig looks like this, because all cloned repositories require these settings:
> [sendemail]
>         from = Olaf Hering <olaf@aepfle.de>
>         envelopesender = olaf@aepfle.de
>         chainreplyto = false
>         ccover = yes
>         smtpencryption = tls
>         smtpdomain = sender
>         smtppass = smtppass
>         smtpAuth = PLAIN
>         smtpserver = smtp.strato.de
>         smtpuser = smtpuser
>         confirm = always
>         assume8bitEncoding = yes
>         transferEncoding = 8bit
>
> Now there is that one repo that requires this:
>
> [sendemail]
>         from = Olaf Hering <a@b.c>
>         envelopesender = a@b.c
>         smtpserver = otherhost
>
> That "otherhost" does just plain oldstyle unencrypted SMTP.
>
> How do I undo the global sendemail settings for that one repo?
> Setting the knobs to empty strings does not help:
> Command unknown: 'AUTH' at /usr/lib/git/git-send-email line 1455.
>
> It seems the global smtpuser is causing the error.

There isn't any way to do this, the only way out is the hack of using
conditional includes and placing this repository in some special
location.

In general it would be very nice if git learned to conditionally pay
attention to config from various places, I've been meaning to work on
this but haven't figured out a good syntax for it (suggestions
welcome!). Things I'd like to do:

1) Set some config in e.g. ~/.gitconfig saying that I want to ignore
   everything from /etc/gitconfig, or in /some/repo/.git/config saying I
   want to ignore ~/.gitconfig but not /etc/gitconfig.

2) Ditto #1 but more granular, e.g. for your use-case saying you're OK
   with grabbing ~/.gitconfig, but you'd like to ignore all sendemail.*
   values from there, or say in your local .git/config that you'd like
   to ignore all previously set sendemail.* no matter where it came
   from.

3) Ability to re-arrange the config priority, right now it's hardcoded
   that we look at /etc/gitconfig, then ~/.gitconfig then your
   .git/config. You can add a config for ~/work with the conditional
   includes, but it would be nice (just as a general thing) to also
   re-arrange things so /etc/gitconfig gets parsed last or whatever.

   I don't really have a use-case for that, but adding such priorities
   would be simple once we had support for #1 and #2, just some
   "priority" integer you could override for each file, and we'd set
   default values for them, e.g. 10 for /etc/gitconfig, 20 for
   ~/.gitconfig, 40 for .git/config etc.

For any of this to work we'd need to re-arrange the config code so that
we'd fully parse all the config files first, and consider any such
"ignore the thing before me" rules in each file, and then make a second
pass over the config data

The ulterior motive I want this for is to eventually support some
facility where we can safely load a .gitconfig from clone repos, since
once we have this for other reasons (and as noted above, it would be
useful for that in its own right) we can load .gitconfig from some
untrusted source, because we're going to be able to say that we only
trust the repo's .gitconfig to set sendemail.to or whatever, but nothing
else.

Previous ramblings from me on this subject:
https://public-inbox.org/git/87zi6eakkt.fsf@evledraar.gmail.com/

So maybe something like this in a .git/config

    # Reject all previous such [config] overrides, by default we'd add
    # them (as default in git config)
    [config]
    reject = *
    [config "system"]
    priority = 50
    reject = *
    accept = sendmail.*
    [config "global"]
    reject = *
    accept = sendmail.*

And eventually have git itself mark up each config option on some scale
of least harmful (sendmail.to & friends) to most harmful (executing
shell aliases), and:

    # Remote maintained untrusted config
    [config "repo"]
    acceptLevel = least-harmful

Or whatever toggle to include some default policy shipped with
git. Actually we could just do that with more generally with config
includes if we learned some syntax for including some templates shipped
with git itself.

  reply	other threads:[~2018-04-05  8:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  7:23 How to configure sendemail for no-auth? Olaf Hering
2018-04-05  8:42 ` Ævar Arnfjörð Bjarmason [this message]
2018-04-05  8:49   ` How to undo previously set configuration? Olaf Hering
2018-04-05 11:21     ` Ævar Arnfjörð Bjarmason
2018-04-05 12:03       ` Randall S. Becker
2018-04-05 13:25       ` Olaf Hering
2018-04-05 16:32         ` Jeff King
2018-04-06 15:55           ` Olaf Hering
2018-04-06 16:15             ` Jeff King
2018-04-06 16:57             ` Rafael Ascensao
2018-04-06 17:50               ` Jeff King
2018-04-05 10:24 ` How to configure sendemail for no-auth? astian
2018-04-05 10:27 ` astian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lkq11ug.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).