git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Chris Zehner via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Chris Zehner <cbzehner@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 0/1] gitignore: ignore comments on the same line as a pattern
Date: Tue, 01 Oct 2019 20:13:12 -0700 (PDT)	[thread overview]
Message-ID: <pull.370.git.gitgitgadget@gmail.com> (raw)

Why make this change?
=====================

Add the ability to use # to put comments after ignore patterns. This is
useful for documenting the reason for particular ignore patterns inclusion
and structure.

Right now a common convention in .gitignore files is to group patterns by
similarity, using new lines beginning with one or more # characters as
headings to explain these groupings. This works well when clarifying why
broad classes of things are ignored, e.g. # build artifacts followed by
several patterns.

When leaving comments about a particular pattern it can be difficult to
distinguish comments about a single patterns from comments used for file
organization.

Comments left after a pattern are unambiguously related to that line, and
that line only.

What should this change do?
===========================

The entirety of a string after a non-escaped #, including the #, is removed
from the pattern in a .gitignore file.

Why make the change this way?
=============================

I don't normally write C, so I probably overlooked more idiomatic ways to do
this. This is done similarly to the way trim_trailing_spaces removes
extraneous spaces from patterns.

Potentially this change could be combined with the existing code for
trim_trailing_spaces, but the logic is slightly different and it seems to me
that the difference in naming aids readability by making it clear what the
responsibilities are for each function.

How can we test this change works?
==================================

That's one area I'd like help with, please.

Test cases:

/pattern/to/match
# Existing comment
/pattern/with/comment # This comment is ignored
/pattern/with/\#octothorpe # \#octothorpe is ignored

I wasn't sure where the correct place to add these would be, I didn't see
(and potentially overlooked) any tests in /t/* that cover this
functionality. Would someone be willing to provide a pointer to the correct
place to add these tests?

Signed-off-by: Chris Zehner cbzehner@gmail.com [cbzehner@gmail.com]

Chris Zehner (1):
  gitignore: ignore comments on the same line as a pattern

 Documentation/gitignore.txt |  8 ++++++--
 dir.c                       | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)


base-commit: bc12974a897308fd3254cf0cc90319078fe45eea
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-370%2Fcbzehner%2Fgitignore-pattern-comment-oneline-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-370/cbzehner/gitignore-pattern-comment-oneline-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/370
-- 
gitgitgadget

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02  3:13 Chris Zehner via GitGitGadget [this message]
2019-10-02  3:13 ` [PATCH 1/1] gitignore: ignore comments on the same line as a pattern Chris Zehner via GitGitGadget
2019-10-02  7:02   ` Junio C Hamano
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=pull.370.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=cbzehner@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).