git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git should not use a default user.email config value

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Aug 14, 2013, 07:09 UTC
Message-ID
<520B2D11.2080405@alum.mit.edu>
In-Reply-To
<20130813114635.GA16506@sigill.intra.peff.net>
On 08/13/2013 01:46 PM, Jeff King wrote:
Show 30 quoted lines
> On Tue, Aug 13, 2013 at 09:05:40PM +1000, Andrew Ardill wrote:
> 
>> I applied this on top of latest next (1da3ebde8999d07), and it worked
>> perfectly for my use case.
>>
>> For what it's worth, it also passed the test suite!
>>
>> Would be great to see this, or something on the same theme, get into
>> master. I'd be happy to review patches/write tests/write documentation
>> if needed.
> 
> Like I said, I do not have a particular use for it, but I don't think it
> would hurt anybody who does not use it. If you want to polish it up into
> a real patch with docs and tests, I don't mind.
> 
> The only downside I can think of is that we might want to use the
> subsection in "include.SUBSECTION.*" for some other limiting conditions
> (e.g., "only include this config when running version >= X.Y", or even
> "include only when environment variable FOO is true").
> 
> I guess we could do something like:
> 
>   [include "repo:...your regex here..."]
>     path = .gitconfig-only-for-some-repos
>   [include "env:USE_MY_MAGIC_CONFIG"]
>     path = .gitconfig-only-when-magic-env-set
> 
> Adding the "repo:" prefix for this repo-dir matching is pretty trivial.
> Adding a similar env-matching is only slightly less trivial; but does
> anybody actually want it?

Gaaak! Let me again plead for supporting a post-clone hook rather than inventing some crazy config-file syntax that is becoming ever more complicated. A post-clone hook would make all of these things that have been suggested pretty easy, and would also open lots of other possibilities, all without further changes in git.core, like (I'm just brainstorming here):

    #! /bin/sh
    remote="$1"
    ln -s $(HOME)/.githooks/* .git/hooks
    case "$(git --version)" in
    *.1.[78].*)
        git config include.path "$(HOME)/.gitinclude
        ;;
    esac
    echo "(cd $(pwd) && git gc)" >>"$(HOME)/cron.weekly/git-gc"
    case "$remote" in
    *.work.com/*)
        git config user.email me@work.com
        ;;
    *.github.com/*)
        git config user.email me@debian.org
        ;;
    *)
        echo '### Remember to set user.email ###'
        ;;
    esac
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Junio C HamanoNext: Jeff King
Message 40 of 46 in “Re: git should not use a default user.email config value”
  1. Jonathan NiederAug 9, 2013
  2. Thorsten GlaserAug 9, 2013
  3. Felipe ContrerasAug 9, 2013
  4. Matthieu MoyAug 13, 2013
  5. Jeff KingAug 9, 2013
  6. Junio C HamanoAug 9, 2013
  7. Jeff KingAug 10, 2013
  8. Jonathan NiederAug 10, 2013
  9. Jeff KingAug 10, 2013
  10. Jonathan NiederAug 10, 2013
  11. Jeff KingAug 10, 2013
  12. Jonathan NiederAug 9, 2013
  13. Jeff KingAug 10, 2013
  14. Michael HaggertyAug 10, 2013
  15. Jeff KingAug 10, 2013
  16. Michael HaggertyAug 10, 2013
  17. Thorsten GlaserAug 10, 2013
  18. Andreas SchwabAug 10, 2013
  19. Greg TroxelAug 12, 2013
  20. Junio C HamanoAug 10, 2013
  21. Andrew ArdillAug 12, 2013
  22. Jeff KingAug 12, 2013
  23. Michael HaggertyAug 12, 2013
  24. Jeff KingAug 12, 2013
  25. Andrew ArdillAug 12, 2013
  26. Jeff KingAug 12, 2013
  27. Andrew ArdillAug 13, 2013
  28. Jeff KingAug 13, 2013
  29. Jeff KingAug 13, 2013
  30. Andrew ArdillAug 13, 2013
  31. Jeff KingAug 13, 2013
  32. Junio C HamanoAug 13, 2013
  33. Matthieu MoyAug 14, 2013
  34. Jeff KingAug 14, 2013
  35. Matthieu MoyAug 14, 2013
  36. Junio C HamanoAug 14, 2013
  37. Matthieu MoyAug 14, 2013
  38. conditional config syntaxJeff King, Aug 14, 2013
  39. Junio C HamanoAug 14, 2013
  40. Michael HaggertyAug 14, 2013
  41. Jeff KingAug 14, 2013
  42. Junio C HamanoAug 13, 2013
  43. Matthieu MoyAug 13, 2013
  44. Aaron SchrabAug 11, 2013
  45. Matthieu MoyAug 13, 2013
  46. Thorsten GlaserAug 13, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.