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

Re: [PATCH 1/2] dir: warn about trailing spaces in exclude pattern

From
Torsten Bögershausen <tboegi@web.de>
Date
Feb 8, 2014, 14:33 UTC
Message-ID
<52F6404C.1080107@web.de>
In-Reply-To
<1391847004-22810-2-git-send-email-pclouds@gmail.com>
On 2014-02-08 09.10, Nguyễn Thái Ngọc Duy wrote:
Show 19 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  dir.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/dir.c b/dir.c
> index b35b633..9edde44 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -491,6 +491,16 @@ void clear_exclude_list(struct exclude_list *el)
>  	el->filebuf = NULL;
>  }
>  
> +static void check_trailing_spaces(const char *fname, char *buf)
> +{
> +	int len = strlen(buf);
> +	while (len && buf[len - 1] == ' ')
> +		len--;
> +	if (buf[len] != '\0')
Do we need the while loop here, (when we only warn) ?
> +		warning(_("%s: trailing spaces in '%s'. Please quote them."),
> +			fname, buf);
> +}
This is nice. However we can hint the user that there are 2 choices: 
		warning(_("%s: trailing spaces in '%s'. Please remove them or quote them."),
Show 13 quoted lines
> +
>  int add_excludes_from_file_to_list(const char *fname,
>  				   const char *base,
>  				   int baselen,
> @@ -542,6 +552,7 @@ int add_excludes_from_file_to_list(const char *fname,
>  		if (buf[i] == '\n') {
>  			if (entry != buf + i && entry[0] != '#') {
>  				buf[i - (i && buf[i-1] == '\r')] = 0;
> +				check_trailing_spaces(fname, entry);
>  				add_exclude(entry, base, baselen, el, lineno);
>  			}
>  			lineno++;
> 
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 13 in “Ignore trailing spaces in .gitignore”
  1. 0/2 Ignore trailing spaces in .gitignoreNguyễn Thái Ngọc Duy, Feb 8, 2014
  2. 1/2 dir: warn about trailing spaces in exclude patternNguyễn Thái Ngọc Duy, Feb 8, 2014
  3. Torsten BögershausenFeb 8, 2014
  4. 2/2 dir: ignore trailing spaces in exclude patternsNguyễn Thái Ngọc Duy, Feb 8, 2014
  5. Jeff KingFeb 8, 2014
  6. Duy NguyenFeb 8, 2014
  7. Jeff KingFeb 10, 2014
  8. 0/2 Ignore trailing spaces in .gitignoreNguyễn Thái Ngọc Duy, Feb 9, 2014
  9. 1/2 dir: warn about trailing spaces in exclude patternsNguyễn Thái Ngọc Duy, Feb 9, 2014
  10. 2/2 dir: ignore trailing spaces in exclude patternsNguyễn Thái Ngọc Duy, Feb 9, 2014
  11. Junio C HamanoFeb 10, 2014
  12. Duy NguyenFeb 10, 2014
  13. Junio C HamanoFeb 10, 2014

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.