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

Re: [PATCH] Support "core.excludesfile = ~/.gitignore"

From
KCKarl Chen <quarl@cs.berkeley.edu>
Date
Aug 24, 2008, 08:40 UTC
Message-ID
<quack.20080824T0140.lth3aku956e@roar.cs.berkeley.edu>
In-Reply-To
<7vsksw92nh.fsf@gitster.siamese.dyndns.org>
>>>>> On 2008-08-22 14:10 PDT, Junio C Hamano writes:
    Junio> Karl Chen <quarl@cs.berkeley.edu> writes:
    >> Another idea is to have a non-absolute path be interpreted
    >> relative to the location of .gitconfig.
    Junio> If we were to support relative paths, I think it would
    Junio> be useful and consistent if a relative path found in
    Junio> ".git/config" is relative to the work tree root, in
    Junio> "config" in a bare repository relative to the bare
    Junio> repository, and in "$HOME/.gitconfig" relative to
    Junio> $HOME.

Makes sense to support it everywhere. For .git/config, isn't it more consistent for it to be relative to .git?

    Junio> I am not sure what a relative path in "/etc/gitconfig"
    Junio> should be relative to, though.

Why not just relative to the location of that file? Normally /etc, but if some distro customizes the location of /etc/gitconfig (/etc/git/config), or on non-Linux/posix systems it's somewhere else, or git is installed in /usr/local or /opt or $HOME, then it's still relative to the location of system gitconfig.

    Junio> However, this has a technical difficulty.  When
    Junio> configuration values are read, the code that knows what
    Junio> the value means does not in general know which
    Junio> configuration file is being read from.
Sounds like a refactoring issue.
    Junio> It is quite likely that somebody would want you to
    Junio> interpret "~name/" if you advertize that you support
    Junio> "~/", so you would need to call getpwuid() eventually
    Junio> if you go down this path.  I wonder how this would
    Junio> affect Windows folks.

I would be happy either way. Though since git uses getenv("HOME") to find ~/.gitconfig, I can see arguments for looking for the ignore file there also, in case it's different.

    Junio> we would need a "--path" option to "git config" (the
    Junio> idea is similar to existing "--bool" option) so that
    Junio> calling scripts can ask the same "magic" performed to
    Junio> configuration variables' values before being reported.
Sounds fine.

So, being new to git development, am I correctly assessing your response as "with refinement this can be included in git"?

Relative paths and ~ (and $HOME) are all mutually compatible so they could all be implemented. If $HOME were supported directly (either just "$HOME" or parsing all $ENVVARS) then it'd be easier to decide to use getpwuid for ~. Personally I'd use: 1) relative path, 2) $HOME (as "~" or "$HOME"), 3) getpwuid (as "~")

Karl
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 45 in “Support "core.excludesfile = ~/.gitignore"”
  1. Support "core.excludesfile = ~/.gitignore"Karl Chen, Aug 22, 2008
  2. Eric RaibleAug 22, 2008
  3. Bert WesargAug 22, 2008
  4. Junio C HamanoAug 22, 2008
  5. Karl ChenAug 24, 2008
  6. Junio C HamanoAug 24, 2008
  7. Jeff KingAug 24, 2008
  8. Junio C HamanoAug 24, 2008
  9. Jeff KingAug 24, 2008
  10. Junio C HamanoAug 24, 2008
  11. limiting relationship of git dir and worktree (was Re: [PATCH] Support "core.excludesfile = ~/.gitignore")Jeff King, Aug 24, 2008
  12. Dropping core.worktree and GIT_WORK_TREE support (was Re: limiting relationship of git dir and worktree)Junio C Hamano, Aug 25, 2008
  13. Miklos VajnaAug 25, 2008
  14. Junio C HamanoAug 25, 2008
  15. Miklos VajnaAug 25, 2008
  16. Nguyen Thai Ngoc DuyAug 25, 2008
  17. git diff/diff-index/diff-files: call setup_work_tree()Miklos Vajna, Aug 25, 2008
  18. Nguyen Thai Ngoc DuyAug 25, 2008
  19. Miklos VajnaAug 25, 2008
  20. git diff/diff-index/diff-files: call setup_work_tree()Miklos Vajna, Aug 25, 2008
  21. Nguyen Thai Ngoc DuyAug 25, 2008
  22. Junio C HamanoAug 26, 2008
  23. diff*: fix worktree setupNguyễn Thái Ngọc Duy, Aug 28, 2008
  24. Junio C HamanoAug 25, 2008
  25. Miklos VajnaAug 25, 2008
  26. Michael J GruberAug 26, 2008
  27. Jeff KingAug 27, 2008
  28. Support "core.excludesfile = ~/.gitignore"Karl Chen, Aug 25, 2008
  29. Johannes SixtAug 26, 2008
  30. Jeff KingAug 27, 2008
  31. Karl ChenAug 27, 2008
  32. Junio C HamanoAug 27, 2008
  33. Expand ~ and ~user in core.excludesfile, commit.templateKarl Chen, Aug 28, 2008
  34. Jeff KingAug 29, 2008
  35. Junio C HamanoAug 29, 2008
  36. Expand ~ and ~user in core.excludesfile, commit.templateKarl Chen, Aug 29, 2008
  37. Junio C HamanoAug 29, 2008
  38. Karl ChenAug 29, 2008
  39. Junio C HamanoAug 29, 2008
  40. Karl ChenAug 29, 2008
  41. Junio C HamanoAug 30, 2008
  42. Jeff KingAug 30, 2008
  43. Johannes SixtAug 29, 2008
  44. Karl ChenAug 27, 2008
  45. Junio C HamanoAug 27, 2008

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.