threads / patch / 22596

patchgit-archive documentation: .gitattributes must be committed

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

## tl;dr

8 messages between Feb 10, 2010 and Feb 11, 2010. Diffs are folded; open one to read it.

replies: 7people: 3as markdown or json

Francois Marier· Feb 10, 2010, 02:51 UTC · lore

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(-)
Show changes to Documentation/git-archive.txt +3 −0
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· Feb 10, 2010, 19:07 UTC · re: Francois Marier · lore

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

Am 10.02.2010 03:51, schrieb Francois Marier:
Show 26 quoted lines
> 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· Feb 10, 2010, 19:27 UTC · re: René Scharfe · lore

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

René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 11 quoted lines
>> +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· Feb 10, 2010, 19:33 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> 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· Feb 10, 2010, 20:00 UTC · re: Junio C Hamano · lore

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

Am 10.02.2010 20:27, schrieb Junio C Hamano:
Show 20 quoted lines
> 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· Feb 10, 2010, 20:18 UTC · re: René Scharfe · lore

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

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· Feb 10, 2010, 20:33 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> 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(-)
Show changes to Documentation/git-archive.txt +8 −0
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· Feb 11, 2010, 03:48 UTC · re: Junio C Hamano · lore

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

On 2010-02-10 at 12:33:58, Junio C Hamano wrote:
Show 7 quoted lines
> +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

← back to recent threads