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

Re: Git attributes ignored for root directory

From
GBGioele Barabucci <gioele@svario.it>
Date
Oct 5, 2011, 17:56 UTC
Message-ID
<4E8C9A35.5030504@svario.it>
In-Reply-To
<7vd3eb8hkb.fsf@alter.siamese.dyndns.org>
On 05/10/2011 19:38, Junio C Hamano wrote:
Show 8 quoted lines
>> In fact the support for gitattributes using patterns involving "." was
>> pretty spotty in v1.7.6 too.  For example,
>
> The attribute patterns (or exclude patterns for that matter) were never
> designed to name "the current directory". The way to name "everything *in*
> this directory" has always been to say "*" (the "* text=auto" example in
> the documentation says it shows how to set the attribute "for all
> files"). Admittedly the pattern may miss ".*" files.

What if I do not want to say things about the "content" of the directory but about the directory itself? This is exactly my case.

> I have to agree that things like "./" and "."  were outside the scope of
> the design; in some cases undefined behaviour given to such patterns may
> have made sense but that was mere accident.
Actually what I have in my `~/.gitattributes` is
     /. show_in_prompt=no
Anyway, I see a conflict between
>   - A leading slash matches the beginning of the pathname.
>     For example, "/{asterisk}.c" matches "cat-file.c" but not
>     "mozilla-sha1/sha1.c".
and
>   - If the pattern is a single dot and nothing else, it matches everything
>     in the current directory.

in the first case `.` is treated as a "glob dot", while in the second case it is treated as a "regexp dot". I would find this confusing.

Patterns can match directories using `/foo`. Why don't you just say that `.` is equivalent to `./` and `/foo/.` is equivalent to `/foo`?

> So "./" in .gitignore or .gitattributes at the toplevel would match all
> the top-level directories and files but does not apply to the paths
> contained in the matched directories. "." in .gitignore or .gitattributes
> at the toplevel would match everything under the sun.

In the case of `.gitignore`, `/foo/.` and `/foo/` would have the same effect and they look sane to me.

> Would it be sensible to assume that users would not be surprised if
> ". text=auto" meant that the attribute applies to every file in the
> worktree?

I would be surprised as I expect `.` to be a "glob dot". But maybe it is just me and my prejudices :)

Bye,
-- 
Gioele Barabucci <gioele@svario.it>
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 13 in “Git attributes ignored for root directory”
  1. Gioele BarabucciOct 4, 2011
  2. Michael HaggertyOct 5, 2011
  3. Gioele BarabucciOct 5, 2011
  4. Junio C HamanoOct 5, 2011
  5. Gioele BarabucciOct 5, 2011
  6. Junio C HamanoOct 5, 2011
  7. Gioele BarabucciOct 5, 2011
  8. Junio C HamanoOct 5, 2011
  9. Michael HaggertyOct 12, 2011
  10. Junio C HamanoOct 12, 2011
  11. Gioele BarabucciOct 13, 2011
  12. Johannes SixtOct 13, 2011
  13. Junio C HamanoOct 13, 2011

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.