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, 14:47 UTC
Message-ID
<4E8C6DF7.9050406@svario.it>
In-Reply-To
<4E8C481A.1070808@alum.mit.edu>
On 05/10/2011 14:05, Michael Haggerty wrote:
Show 12 quoted lines
> On 10/04/2011 08:52 PM, Gioele Barabucci wrote:
>> With the newer v1.7.7 I get this, instead:
>>
>>      .: show_in_prompt: unspecified
>>
>> I see in the release notes of 1.7.7-rc1 that `check-attr` has been
>> changed to allow relative paths to be specified. Maybe this error is
>> related to that change.
>
> Indeed, your use case is broken by
>
> f5114a40c0d0276ce6ff215a3dc51eb19da5b420
Wow, debug-by-changelog :)
> In fact the support for gitattributes using patterns involving "." was
> pretty spotty in v1.7.6 too.  For example,
[...]
Show 5 quoted lines
> It's not to hard to fix your particular use case.  But for a real fix,
> we would need to decide what is the correct behavior in all of the lines
> above marked "?"; specifically, should "." match every subdirectory
> under a given directory, does it match only the directory containing the
> .gitattributes file, or is this construct illegal?
I do not know what the correct behavior should be, but here is my use case.

I use git to version almost all my $HOME dir. In addition to my usual files there are also separate project repositories under $HOME. I enjoy using a git-enabled prompt in those projects' dirs but not in my $HOME dir.

So I have this code somewhere in my `~/.bashrc`:
     local show_status="$(git check-attr show_in_prompt -- .)"
     local show_pattern='^\.: show_in_prompt: (.*)$'
     # add the following line to .gitattributes
     #
     #     /. show_in_prompt=no
     local show_in_prompt='yes'
     if [[ ${show_status} =~ ${show_pattern} ]]; then
            show_in_prompt="${BASH_REMATCH[1]}"
     fi
     if [ "${show_in_prompt}" == 'no' ]; then
             return
     fi

As you see in my the line of this code, I exploit the fact that "." refers to the root git dir, not to the current dir, to simplify the code. Otherwise I would had to discover what is the path of the current dir relative to its root git dir, something that I'd like to avoid as this code runs every time the prompt is shown.

This is just my personal use case. On the other hand, the first time I looked at check-attr I found it strange that paths were meant as relative to the root git dir ("." in "/foo" = "/") and not expanded from the current dir ("." in "/foo" = "/foo").

Bye,
-- 
Gioele Barabucci <gioele@svario.it>
Previous: Michael HaggertyNext: Junio C Hamano
Message 3 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.