# [PATCH] git-archive documentation: .gitattributes must be committed

8 messages from 2010-02-10 to 2010-02-11. Participants: Francois Marier, René Scharfe, Junio C Hamano.
Thread: https://gitlist.dev/t/22596

## Francois Marier, 2010-02-10 02:51

Subject: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <1265770284-14830-1-git-send-email-fmarier@gmail.com>
URL: https://gitlist.dev/e/1265770284-14830-1-git-send-email-fmarier%40gmail.com

```
Add a note to the documentation stating that the .gitattributes
file must be present (i.e. committed) in the named tree that is
exported.

This can be a bit confusing because it's different from .gitignore
which takes effect as soon as the file is created.

Signed-off-by: Francois Marier <fmarier@gmail.com>
---
 Documentation/git-archive.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 799c8b6..fcd681d 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -112,6 +112,9 @@ export-subst::
 	expand several placeholders when adding this file to an archive.
 	See linkgit:gitattributes[5] for details.
 
+The .gitattributes file must be present in the named tree for it to take
+effect. Uncommitted attributes will not be considered in exports.
+
 EXAMPLES
 --------
 git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::
-- 
1.6.6.1

```

## René Scharfe, 2010-02-10 19:07

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <4B7303FC.6070701@lsrfire.ath.cx>
URL: https://gitlist.dev/e/4B7303FC.6070701%40lsrfire.ath.cx
In-Reply-To: <1265770284-14830-1-git-send-email-fmarier@gmail.com>

```
Am 10.02.2010 03:51, schrieb Francois Marier:
> Add a note to the documentation stating that the .gitattributes
> file must be present (i.e. committed) in the named tree that is
> exported.
> 
> This can be a bit confusing because it's different from .gitignore
> which takes effect as soon as the file is created.
> 
> Signed-off-by: Francois Marier <fmarier@gmail.com>
> ---
>  Documentation/git-archive.txt |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
> index 799c8b6..fcd681d 100644
> --- a/Documentation/git-archive.txt
> +++ b/Documentation/git-archive.txt
> @@ -112,6 +112,9 @@ export-subst::
>  	expand several placeholders when adding this file to an archive.
>  	See linkgit:gitattributes[5] for details.
>  
> +The .gitattributes file must be present in the named tree for it to take
> +effect. Uncommitted attributes will not be considered in exports.
> +
>  EXAMPLES
>  --------
>  git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::

Yeah, the description of --worktree-attributes is a bit terse.  The
lines you add make it appear almost as if this switch doesn't exist,
though; perhaps add a "unless --worktree-attributes is given" or similar
to one of the new sentences?

René

```

## Junio C Hamano, 2010-02-10 19:27

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <7v1vgsao21.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1vgsao21.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4B7303FC.6070701@lsrfire.ath.cx>

```
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

>> +The .gitattributes file must be present in the named tree for it to take
>> +effect. Uncommitted attributes will not be considered in exports.
>> +
>>  EXAMPLES
>>  --------
>>  git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::
>
> Yeah, the description of --worktree-attributes is a bit terse.  The
> lines you add make it appear almost as if this switch doesn't exist,
> though; perhaps add a "unless --worktree-attributes is given" or similar
> to one of the new sentences?

My impression has always been that people use attributes with archive more
often to _tweak_ how the archive is produced after the fact, and they do
so by modifying checked out .gitattributes (or $GIT_DIR/info/attributes)
than allowing a possibly stale .gitattributes file etched in stone^Wtree
being archived.  So in that sense, probably --worktree-attributes should
have been the default.

By the way, if you commit the attributes file, then commit the removal of
that attributes file, would that removed attributes file take effect when
you archive HEAD^ (which still had the attribues file)?  That's how I read
what the added description claims, but I somehow suspect that is not what
actually happens.

```

## Junio C Hamano, 2010-02-10 19:33

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <7vocjw998t.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vocjw998t.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7v1vgsao21.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> By the way, if you commit the attributes file, then commit the removal of
> that attributes file, would that removed attributes file take effect when
> you archive HEAD^ (which still had the attribues file)?  That's how I read
> what the added description claims, but I somehow suspect that is not what
> actually happens.

Scratch this part, please.  You do read the tree into the index to make
it happen.

```

## René Scharfe, 2010-02-10 20:00

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <4B731043.6010108@lsrfire.ath.cx>
URL: https://gitlist.dev/e/4B731043.6010108%40lsrfire.ath.cx
In-Reply-To: <7v1vgsao21.fsf@alter.siamese.dyndns.org>

```
Am 10.02.2010 20:27, schrieb Junio C Hamano:
> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
> 
>>> +The .gitattributes file must be present in the named tree for it to take
>>> +effect. Uncommitted attributes will not be considered in exports.
>>> +
>>>  EXAMPLES
>>>  --------
>>>  git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::
>>
>> Yeah, the description of --worktree-attributes is a bit terse.  The
>> lines you add make it appear almost as if this switch doesn't exist,
>> though; perhaps add a "unless --worktree-attributes is given" or similar
>> to one of the new sentences?
> 
> My impression has always been that people use attributes with archive more
> often to _tweak_ how the archive is produced after the fact, and they do
> so by modifying checked out .gitattributes (or $GIT_DIR/info/attributes)
> than allowing a possibly stale .gitattributes file etched in stone^Wtree
> being archived.  So in that sense, probably --worktree-attributes should
> have been the default.

That was the case up to ba053ea9 (April 2009, archive: do not read
.gitattributes in working directory).  I think that the current
behaviour makes sense because it provides a repeatable default.

René

```

## Junio C Hamano, 2010-02-10 20:18

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <7vr5os7sl2.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr5os7sl2.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4B731043.6010108@lsrfire.ath.cx>

```
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

> ...  I think that the current
> behaviour makes sense because it provides a repeatable default.

I wouldn't insist on changing the default again too strongly, but I think
the --worktree-attributes option should be advertised better in the
documentation, as that mode of operation seems to match what the users
expect better, and I think that is how this thread started.

```

## Junio C Hamano, 2010-02-10 20:33

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <7veiks7rux.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7veiks7rux.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7vr5os7sl2.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
>
>> ...  I think that the current
>> behaviour makes sense because it provides a repeatable default.
>
> I wouldn't insist on changing the default again too strongly, but I think
> the --worktree-attributes option should be advertised better in the
> documentation, as that mode of operation seems to match what the users
> expect better, and I think that is how this thread started.

How about this?  Instead of stopping at saying "it is taken from the tree
and must be committed, period", we should continue giving insn to help
people who didn't do so to achieve what they want to do.

-- >8 --
Subject: archive documentation: attributes are taken from the tree by default

By default, git-archive takes attributes from the tree being archived.
People however often wonder why their attempts to affect the way how the
command archives their tree by changing .gitattributes in their work tree
fail.

Add a bit of explanatory note to tell them how to achieve what they want
to do.

Noticed-by: Francois Marier
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-archive.txt |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 799c8b6..8d3e666 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -112,6 +112,14 @@ export-subst::
 	expand several placeholders when adding this file to an archive.
 	See linkgit:gitattributes[5] for details.
 
+Note that attributes are by default taken from the `.gitattributes` files
+in the tree that is being archived.  If you want to tweak the way the
+output is generated after the fact (e.g. you committed without adding an
+appropriate export-ignore in its `.gitattributes`), adjust the checked out
+`.gitattributes` file as necessary and use `--work-tree-attributes`
+option.  Alternatively you can keep necessary attributes that should apply
+while archiving any tree in your `$GIT_DIR/info/attributes` file.
+
 EXAMPLES
 --------
 git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::

```

## Francois Marier, 2010-02-11 03:48

Subject: Re: [PATCH] git-archive documentation: .gitattributes must be committed
Message-ID: <20100211034802.GS9853@isafjordur.dyndns.org>
URL: https://gitlist.dev/e/20100211034802.GS9853%40isafjordur.dyndns.org
In-Reply-To: <7veiks7rux.fsf@alter.siamese.dyndns.org>

```
On 2010-02-10 at 12:33:58, Junio C Hamano wrote:
> +Note that attributes are by default taken from the `.gitattributes` files
> +in the tree that is being archived.  If you want to tweak the way the
> +output is generated after the fact (e.g. you committed without adding an
> +appropriate export-ignore in its `.gitattributes`), adjust the checked out
> +`.gitattributes` file as necessary and use `--work-tree-attributes`
> +option.  Alternatively you can keep necessary attributes that should apply
> +while archiving any tree in your `$GIT_DIR/info/attributes` file.

Looks good to me.

-- 
Francois Marier                         identi.ca/fmarier
http://feeding.cloud.geek.nz          twitter.com/fmarier

```
