Re: [PATCH] Document disabling core.whitespace values trailing-space and space-before-tab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, it gets stranger and stranger!

Nanako Shiraishi nanako3-at-lavabit.com |Lists| wrote:
The '-trailing-space' syntax to disable the trailing-space setting is not obvious and not documented as far as I can see. I would have
assumed a value of '' would disable it.

Doesn't gitattributes(5) describe the overall syntax in detail?

First, git-config.1 does not mention gitattributes except for specific
settings. core.whitespace is not one of these.

gitattributes.5 has:
Sometimes you would need to override an setting of an attribute for a
path to unspecified state. This can be done by listing the name of the attribute prefixed with an exclamation point !.

note that this is ! before the *name* of the attribute, and for "Checking whitespace errors / whitespace":

The core.whitespace configuration variable allows you to define what diff and apply should consider whitespace errors for all paths in the project (See git-config(1)). This attribute gives you finer control per path.
...
Unspecified: Use the value of core.whitespace configuration variable
 to decide what to notice as error.

String: Specify a comma separate list of common whitespace problems to notice in the same format as core.whitespace configuration variable.

So now, git attributes says to unspecify a setting with '!' in front of
the attribute *name*, which for core.whitespace means use the value from
git-config, which if not specified means to error on e.g. trailing-space.

Now, I notice that git's own .gitattributes has this:
* whitespace=!indent,trail,space
*.[ch] whitespace

Which I assume actually works, but is invalid according to git-config.1 and gitattributes.5 because:

For the first line, neither of the values 'indent', 'trail' nor 'space'
are valid for core.whitespace, and the '!' notation is not defined in
neither gitattributes.5 nor in git-config.1 for *values*.

For the second line, gitattributes states generally about attributes that:
Set: The path has the attribute with special value "true"; this is specified by listing only the name of the attribute in the attribute list.

A value of true (unspecified would have required:"*.[ch] !whitespace") is not valid for core.whitespace either.

So now (as I read it), neither git-config.1 nor gitattributes.5 specify how to turn off core.whitespace "elements", but .gitattributes (from git itself) uses one notation (!) with settings that are invalid for other reaons, while "grep core.whitespace t/*" uses another notation (-) to turn off elements.

Also in t/* the elements have various different names, such as: "trail", "trailing", "trailing-space". t/t4019-diff-wserror.sh also uses this:
echo "F whitespace=-trail" >.gitattributes
just to make things interesting!

It seems that there is some inconsistency about this. Perhaps documentation (and changing t/* and .gitattributes accordingly) isn't such a bad idea! :D

Peter
--
Peter Valdemar Mørch
http://www.morch.com
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux