git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
PLPeter Valdemar Mørch (Lists) <4ux6as402@sneakemail.com>
Date
Jul 24, 2008, 09:41 UTC
Message-ID
<48884E56.6070801@sneakemail.com>
In-Reply-To
<20080724172912.6117@nanako3.lavabit.com>
Actually, it gets stranger and stranger!
Nanako Shiraishi nanako3-at-lavabit.com |Lists| wrote:
Show 5 quoted lines
>> 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.
...
Show 6 quoted lines
> 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
Previous: Nanako ShiraishiNext: Junio C Hamano
Message 3 of 8 in “Document disabling core.whitespace values trailing-space and space-before-tab”
  1. Document disabling core.whitespace values trailing-space and space-before-tabPeter Valdemar Mørch (Lists), Jul 24, 2008
  2. Nanako ShiraishiJul 24, 2008
  3. Peter Valdemar Mørch (Lists)Jul 24, 2008
  4. Junio C HamanoJul 25, 2008
  5. Peter Valdemar MørchJul 25, 2008
  6. Peter Valdemar Mørch (Lists)Jul 25, 2008
  7. Junio C HamanoJul 25, 2008
  8. Junio C HamanoJul 25, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.