git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] dir: warn about trailing spaces in exclude pattern
Date: Sat, 08 Feb 2014 15:33:48 +0100	[thread overview]
Message-ID: <52F6404C.1080107@web.de> (raw)
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:
> 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."),
> +
>  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++;
> 

  reply	other threads:[~2014-02-08 14:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-08  8:10 [PATCH 0/2] Ignore trailing spaces in .gitignore Nguyễn Thái Ngọc Duy
2014-02-08  8:10 ` [PATCH 1/2] dir: warn about trailing spaces in exclude pattern Nguyễn Thái Ngọc Duy
2014-02-08 14:33   ` Torsten Bögershausen [this message]
2014-02-08  8:10 ` [PATCH 2/2] dir: ignore trailing spaces in exclude patterns Nguyễn Thái Ngọc Duy
2014-02-08 16:45 ` [PATCH 0/2] Ignore trailing spaces in .gitignore Jeff King
2014-02-08 23:48   ` Duy Nguyen
2014-02-10  1:19     ` Jeff King
2014-02-09  0:26 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
2014-02-09  0:26   ` [PATCH v2 1/2] dir: warn about trailing spaces in exclude patterns Nguyễn Thái Ngọc Duy
2014-02-09  0:26   ` [PATCH v2 2/2] dir: ignore " Nguyễn Thái Ngọc Duy
2014-02-10  4:07 ` [PATCH 0/2] Ignore trailing spaces in .gitignore Junio C Hamano
2014-02-10  4:29   ` Duy Nguyen
2014-02-10  5:04   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F6404C.1080107@web.de \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).