git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Chris Zehner via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Chris Zehner <cbzehner@gmail.com>
Subject: Re: [PATCH 1/1] gitignore: ignore comments on the same line as a pattern
Date: Wed, 02 Oct 2019 16:02:51 +0900	[thread overview]
Message-ID: <xmqqpnjfeijo.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <e448214e87b46dc649781b10727043bc390d9aab.1569985991.git.gitgitgadget@gmail.com> (Chris Zehner via GitGitGadget's message of "Tue, 01 Oct 2019 20:13:13 -0700 (PDT)")

"Chris Zehner via GitGitGadget" <gitgitgadget@gmail.com> writes:

> -   that begin with a hash.
> +   Put a backslash ("`\`") in front of each hash for patterns
> +   containing a hash.
> +
> + - A # after a pattern will be treated as the start of a comment.
> +   Put a backslash ("`\`") in front of each hash for patterns
> +   containing a hash.

Besides being backward incompatible, this looks somewhat misdesigned
by lacking a way to escape a backslash (i.e. what should a project
do if they want a patttern with backslash followed by a hash
literally in there?).

> diff --git a/dir.c b/dir.c
> index cab9c2a458..aeefe142bc 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -658,6 +658,38 @@ void clear_pattern_list(struct pattern_list *pl)
>  	memset(pl, 0, sizeof(*pl));
>  }
>  
> +static void trim_trailing_comments(char *buf)
> +{
> +	char *p, *last_hash = NULL;
> +	int escape_seq = 0;
> +
> +	for (p = buf; *p; p++)
> +	{

Style (see Documentation/CodingGuidelines).  The opening parenthesis
of a control structure like if/for/switch are placed on the same
line, i.e.

	for (p = buf; *p; p++) {

Do we even need a separate 'p', instead of scanning with 'buf' itself?

> +		if (!*p)
> +			return;

What happens when an entry ends with '\' followed by an EOL?  IOW,
what if escape_seq is true here?

> +		switch (*p) {
> +		case '#':
> +			if (escape_seq)
> +			{
> +				escape_seq = 0;
> +				p++;
> +				break;
> +			}
> +			if (!last_hash)
> +				last_hash = p;
> +			break;
> +		case '\\':
> +			escape_seq = 1;
> +			break;

  reply	other threads:[~2019-10-02  7:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02  3:13 [PATCH 0/1] gitignore: ignore comments on the same line as a pattern Chris Zehner via GitGitGadget
2019-10-02  3:13 ` [PATCH 1/1] " Chris Zehner via GitGitGadget
2019-10-02  7:02   ` Junio C Hamano [this message]
2019-10-02  6:51 ` [PATCH 0/1] " 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqpnjfeijo.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=cbzehner@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).