git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Michael Haggerty <mhagger@alum.mit.edu>,
	Jay Soffian <jaysoffian@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jakub Narebski <jnareb@gmail.com>
Subject: config-file includes
Date: Fri, 23 Sep 2011 15:58:29 -0400	[thread overview]
Message-ID: <20110923195829.GA27677@sigill.intra.peff.net> (raw)

On Fri, Sep 23, 2011 at 03:33:41PM -0400, Jeff King wrote:

> [1] I really wish we had an elegant way of versioning meta-information
>     about a repository (like config, info/attributes, etc). I've hacked
>     around this before by having a special meta-branch for each repo,
>     checkout it out in an alternate directory, and then symlinking bits
>     of it into .git. But that's kind of ugly, too.
> 
>     I'm not sure what a good solution would look like. There's a real
>     can of worms with respect to picking and choosing local versus
>     remote bits of meta-information, with some security implications.

Here's one solution I've given a little thought to. Comments welcome.

I've sometimes wanted an "include" mechanism in git config files.
Partially to just keep things tidier, partially to avoid
cutting-and-pasting between some repo-specific config, and partially
because I'd like a conditional inclusion mechanism[1]. I was thinking of
something that would be syntactically compatible but semantically
meaningless in current versions of git, like:

  [include]
  path = /some/file
  path = /some/other/file
  path = ~/some/file/in/your/homedir

You could extend this to look in refs, with something like:

  [include]
  ref = meta:config

which would resolve meta:config to a blob and examine it (i.e., it would
look at refs/heads/meta).

So the procedure for importing and updating config from a remote would
look like:

  git clone project.git
  cd project

  # check that the upstream config looks good
  git show origin/meta:config
  # if so, use it
  git branch meta origin/meta
  git config --add include.ref meta:config

  # later, check updates to upstream's config
  git fetch
  git diff meta origin/meta -- config
  # looks ok, use it
  git branch -f meta origin/meta

And obviously if you wanted to streamline that, you could make "meta"
and "config" well-known names and have clone and fetch interactively
show the config and say "do you want this [y/N]?" or something. Though I
think there is some value to doing it manually, as it gives projects the
flexibility to have different config profiles in their meta branch.

And if you really wanted to live dangerously, you could do:

  git config --add include.ref origin/meta:config

That of course just covers "config". But I think you might be able to do
something similar with core.attributesfile (which could be included from
the config).

-Peff

[1] I want conditional inclusion because sometimes the rules for config
    entries changes from version to version. For example, I have
    pager.diff set to a script in my ~/.gitconfig. But older versions of
    git don't understand non-boolean values and barf. I'd really like to
    do something like:

    [include-ifdef "has-pager-scripts"]
    path = ~/.gitconfig-pager

    where "has-pager-scripts" would be a magic flag compiled into git
    versions that understand that config.

             reply	other threads:[~2011-09-23 19:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23 19:58 Jeff King [this message]
2011-09-26 10:45 ` config-file includes Nguyen Thai Ngoc Duy
2011-09-26 12:36   ` Jeff King
2011-09-26 19:21   ` David Aguilar
2011-09-26 20:05     ` Jeff King
2011-09-26 21:12       ` Junio C Hamano
2011-09-27  2:13       ` Jay Soffian
2011-09-27  2:38         ` Jeff King

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

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

  git send-email \
    --in-reply-to=20110923195829.GA27677@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jaysoffian@gmail.com \
    --cc=jnareb@gmail.com \
    --cc=mhagger@alum.mit.edu \
    /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.
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 NNTP newsgroup(s).