From: Gioele Barabucci <gioele@svario.it>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org
Subject: Re: Git attributes ignored for root directory
Date: Wed, 05 Oct 2011 16:47:19 +0200 [thread overview]
Message-ID: <4E8C6DF7.9050406@svario.it> (raw)
In-Reply-To: <4E8C481A.1070808@alum.mit.edu>
On 05/10/2011 14:05, Michael Haggerty wrote:
> 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,
[...]
> 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>
next prev parent reply other threads:[~2011-10-05 14:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-04 18:52 Git attributes ignored for root directory Gioele Barabucci
2011-10-05 12:05 ` Michael Haggerty
2011-10-05 14:47 ` Gioele Barabucci [this message]
2011-10-05 17:38 ` Junio C Hamano
2011-10-05 17:56 ` Gioele Barabucci
2011-10-05 18:35 ` Junio C Hamano
2011-10-05 20:17 ` Gioele Barabucci
2011-10-05 20:25 ` Junio C Hamano
2011-10-12 22:35 ` Michael Haggerty
2011-10-12 23:12 ` Junio C Hamano
2011-10-13 10:49 ` Gioele Barabucci
2011-10-13 13:16 ` Johannes Sixt
2011-10-13 17:38 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E8C6DF7.9050406@svario.it \
--to=gioele@svario.it \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).