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

Re: [RFC/PATCH] config: honor file permission bits

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 22, 2026, 21:08 UTC
Message-ID
<atp7Pvtp1rdL8Uj_@fruit.crustytoothpaste.net>
In-Reply-To
<xmqqpkx1e9iq.fsf@gitster.g>
On 2026-10-22 at 20:59:57, Junio C Hamano wrote:
Show 30 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Because our updates to an existing file almost never makes
> > modifications in place, and instead create a new "lockfile",
> > propagate the permission bits from the original, copy the contents
> > from the original file while tweaking the contents as needed, and
> > then finally rename the lockfile to replace the original file, you
> > cannot "protect" your .global configuration file from accidental
> > clobbering by doing something like this:
> >
> > 	$ chmod a-w $HOME/.gitconfig
> >
> > Of course, if you make your $HOME directory unwritable, it may
> > protect your .gitconfig from getting updated, but that goes totally
> > against the intuition and is not how you would protect a regular
> > file from getting overwritten.
> >
> > Teach the configuration file writing machinery to inspect the
> > permission bits of the original with access(2) and refrain from
> > doing the usual "write a lockfile and replace the original with it"
> > dance ourselves when we shouldn't be able to write it.
> >
> > Signed-off-by: Junio C Hamano <gitster@pobox.com>
> > ---
> >  config.c          | 22 ++++++++++++++++++++++
> >  t/t1300-config.sh | 30 ++++++++++++++++++++++++++++++
> >  2 files changed, 52 insertions(+)
> 
> Hmph, no responses to this RFC.  I somehow find it hard to believe
> that I was the only person who got annoyed by this behaviour [*].
Sorry, I looked but forgot to respond.  It seems sensible to me.

I don't personally make that file read-only, so it doesn't affect me at all; instead, I just overwrite it with my personal configuration every time I deploy my dotfiles. I still think it's a reasonable thing to do to help those who need it, though.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 11 in “config: honor file permission bits”
  1. config: honor file permission bitsJunio C Hamano, Oct 19, 2026
  2. Junio C HamanoOct 22, 2026
  3. brian m. carlsonOct 22, 2026
  4. Junio C HamanoOct 22, 2026
  5. Patrick SteinhardtOct 23, 2026
  6. Junio C HamanoOct 23, 2026
  7. Patrick SteinhardtOct 26, 2026
  8. Junio C HamanoOct 26, 2026
  9. config: honor file permission bitsJunio C Hamano, Oct 26, 2026
  10. Patrick SteinhardtNov 3, 2026
  11. Junio C HamanoNov 3, 2026

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.