* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 8:14 ` Frans Englich
@ 2009-07-02 11:12 ` Paolo Bonzini
2009-07-02 11:29 ` Frans Englich
2009-07-02 17:05 ` Jeff King
2009-07-02 11:59 ` Jakub Narebski
2009-07-02 17:04 ` Jeff King
2 siblings, 2 replies; 10+ messages in thread
From: Paolo Bonzini @ 2009-07-02 11:12 UTC (permalink / raw)
To: Frans Englich; +Cc: Jeff King, git
>> So as far as I can see, git is behaving exactly as it is supposed to.
>> Maybe you can be more specific about what effect you were trying to
>> achieve by setting gitattributes in the first place?
>
> To exclude it in diffs, such as from `git show`. Take the case where you have
> a grammar file for a parser and generate a source file from it(or any similar
> scenario); the diff for the generated source file is not of interest and is
> just noisy when read as part of a patch. This applies to all kinds of
> generated files. However, this doesn't mean that the file should be treated
> as a binary, and what practicalities that implies.
I am not sure it is a good idea, but you can do this with
FILE diff=/bin/true
> If -diff affects whether a file is treated as a binary, as opposed whether
> it's diff'ed, it would imo make sense to call it -binary.
No, diff affects how a file is diffed. The particular setting "-diff"
diffs the file as if it was binary.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 11:12 ` Paolo Bonzini
@ 2009-07-02 11:29 ` Frans Englich
2009-07-02 11:29 ` Paolo Bonzini
2009-07-02 17:05 ` Jeff King
1 sibling, 1 reply; 10+ messages in thread
From: Frans Englich @ 2009-07-02 11:29 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Jeff King, git
On Thursday 02 July 2009 13:12:28 Paolo Bonzini wrote:
> >> So as far as I can see, git is behaving exactly as it is supposed to.
> >> Maybe you can be more specific about what effect you were trying to
> >> achieve by setting gitattributes in the first place?
> >
> > To exclude it in diffs, such as from `git show`. Take the case where you
> > have a grammar file for a parser and generate a source file from it(or
> > any similar scenario); the diff for the generated source file is not of
> > interest and is just noisy when read as part of a patch. This applies to
> > all kinds of generated files. However, this doesn't mean that the file
> > should be treated as a binary, and what practicalities that implies.
>
> I am not sure it is a good idea, but you can do this with
>
> FILE diff=/bin/true
>
> > If -diff affects whether a file is treated as a binary, as opposed
> > whether it's diff'ed, it would imo make sense to call it -binary.
>
> No, diff affects how a file is diffed. The particular setting "-diff"
> diffs the file as if it was binary.
Aha, then we're maybe at conclusion; if -diff doesn't cause the files to be
treated as binaries, then the phrase "Binary files a/file.txt and b/file.txt
differ" is wrong, it shouldn't read "Binary files", but maybe rather "The
files".
Cheers,
Frans
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 11:29 ` Frans Englich
@ 2009-07-02 11:29 ` Paolo Bonzini
0 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2009-07-02 11:29 UTC (permalink / raw)
To: Frans Englich; +Cc: Paolo Bonzini, Jeff King, git
>>> If -diff affects whether a file is treated as a binary, as opposed
>>> whether it's diff'ed, it would imo make sense to call it -binary.
>> No, diff affects how a file is diffed. The particular setting "-diff"
>> diffs the file as if it was binary.
>
> Aha, then we're maybe at conclusion; if -diff doesn't cause the files to be
^^^^^^^
???
> treated as binaries
Reread carefully.
1) There is no "-diff" attribute. There is a "diff" attribute that
affects *how* (not *whether*) files are diff.
2) A "-" in front of an attribute unsets the attribute.
3) The "diff" attribute, when unset, treats the file as binary.
ergo
4) Using "-diff" in .gitattributes treats the final as binary.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 11:12 ` Paolo Bonzini
2009-07-02 11:29 ` Frans Englich
@ 2009-07-02 17:05 ` Jeff King
1 sibling, 0 replies; 10+ messages in thread
From: Jeff King @ 2009-07-02 17:05 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Frans Englich, git
On Thu, Jul 02, 2009 at 01:12:28PM +0200, Paolo Bonzini wrote:
> >To exclude it in diffs, such as from `git show`. Take the case where you have
> >a grammar file for a parser and generate a source file from it(or any similar
> >scenario); the diff for the generated source file is not of interest and is
> >just noisy when read as part of a patch. This applies to all kinds of
> >generated files. However, this doesn't mean that the file should be treated
> >as a binary, and what practicalities that implies.
>
> I am not sure it is a good idea, but you can do this with
>
> FILE diff=/bin/true
This is a good idea Paolo (and I stole it when responding elsewhere in
the thread ;) ), but it should actually be:
FILE diff=invisible
and then putting
[diff "invisible"]
command = /bin/true
in your config.
-Peff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 8:14 ` Frans Englich
2009-07-02 11:12 ` Paolo Bonzini
@ 2009-07-02 11:59 ` Jakub Narebski
2009-07-02 17:04 ` Jeff King
2 siblings, 0 replies; 10+ messages in thread
From: Jakub Narebski @ 2009-07-02 11:59 UTC (permalink / raw)
To: Frans Englich; +Cc: Jeff King, git
Frans Englich <fenglich@fastmail.fm> writes:
> On Thursday 02 July 2009 07:35:34 Jeff King wrote:
> > On Wed, Jul 01, 2009 at 12:08:35PM +0200, Frans Englich wrote:
> > > Applying -diff Unset to a file using .gittattributes causes "git diff"
> > > to state that the file is a binary even though it isn't, or have been
> > > instructed to be treated as one. See attached script for reproducing.
> >
> > I think you are a little confused by the syntax. Each line of the
> > gitattributes file has a filename pattern and a set of attributes. Each
> > attribute is either set, unset, set to a value, or unspecified. For your
> > example (file.txt and the "diff" attribute), they look like:
>
> Perhaps that should be considered another bug; that invalid syntax is
> accepted, instead of being communicated to the user.
This is not a bug, this is a feature.
You can add extra attributes which are unknown to Git (like "Unset"),
just like you can add config variables in $GIT_DIR/config file which
are unknown to Git, to be used by some wrapper, tool or porcelain. An
example for unknown config variables is e.g. stgit.sender or
stgit.editor (for StGIT patch management interface).
> [...]
> > So as far as I can see, git is behaving exactly as it is supposed to.
> > Maybe you can be more specific about what effect you were trying to
> > achieve by setting gitattributes in the first place?
>
> To exclude it in diffs, such as from `git show`. Take the case where
> you have a grammar file for a parser and generate a source file from
> it(or any similar scenario); the diff for the generated source file
> is not of interest and is just noisy when read as part of a
> patch. This applies to all kinds of generated files. However, this
> doesn't mean that the file should be treated as a binary, and what
> practicalities that implies.
>
> If -diff affects whether a file is treated as a binary, as opposed
> whether it's diff'ed, it would imo make sense to call it -binary.
Actually there exists already "binary" gitattribute, or to be more
exact "binary" built-in attribute macro. "binary" means "-diff -crlf",
as you can see at the bottom of gitattributes(5) manpage.
The message "Binary files differ" is taken from GNU diff, I think.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Bug report: .gitattributes: -diff Unset causes files to be reported as binaries
2009-07-02 8:14 ` Frans Englich
2009-07-02 11:12 ` Paolo Bonzini
2009-07-02 11:59 ` Jakub Narebski
@ 2009-07-02 17:04 ` Jeff King
2 siblings, 0 replies; 10+ messages in thread
From: Jeff King @ 2009-07-02 17:04 UTC (permalink / raw)
To: Frans Englich; +Cc: git
On Thu, Jul 02, 2009 at 10:14:06AM +0200, Frans Englich wrote:
> > I think you are a little confused by the syntax. Each line of the
> > gitattributes file has a filename pattern and a set of attributes. Each
> > attribute is either set, unset, set to a value, or unspecified. For your
> > example (file.txt and the "diff" attribute), they look like:
>
> Perhaps that should be considered another bug; that invalid syntax is
> accepted, instead of being communicated to the user.
It's not invalid syntax; it just doesn't do what you thought it did. And
even though it is _semantically_ useless to git, it is a feature of
gitattributes (and the git config) to allow unknown keys, so that they
can be used by other programs and scripts built on top of git.
> > So as far as I can see, git is behaving exactly as it is supposed to.
> > Maybe you can be more specific about what effect you were trying to
> > achieve by setting gitattributes in the first place?
>
> To exclude it in diffs, such as from `git show`. Take the case where
> you have a grammar file for a parser and generate a source file from
> it(or any similar scenario); the diff for the generated source file is
> not of interest and is just noisy when read as part of a patch. This
> applies to all kinds of generated files. However, this doesn't mean
> that the file should be treated as a binary, and what practicalities
> that implies.
The usual workflow is not to check in generated files at all. You can
mark them with '.gitignore' to make sure they are not actually added.
However, I can imagine a case where your workflow required checking in
generated files (because, e.g., the tools to generate them were
difficult to use or not available to all developers), but most of the
time seeing their diffs is just clutter. So the instruction you want to
give to git is "when diffing these, generate nothing". And that is:
$ echo file.txt diff=invisible >>.gitattributes
$ git config diff.invisible.command /bin/true
Or even some other custom script of your choosing that might show a more
condensed diff.
> If -diff affects whether a file is treated as a binary, as opposed
> whether it's diff'ed, it would imo make sense to call it -binary.
I'm not sure I agree, but even if I did, it is far too late to change
the semantics of the "diff" and "binary" attributes; you would be
breaking the existing setup of many other users.
-Peff
^ permalink raw reply [flat|nested] 10+ messages in thread