-
Notifications
You must be signed in to change notification settings - Fork 26.4k
gitignore: ignore comments on the same line as a pattern #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for your contribution! Please make sure that your commit message focuses on answering the question "why?" more than on "how?", and that it wraps at <= 76 columns per line. Finally send the patch to the mailing list for review. You can use GitGitGadget, submitGit or send it manually. |
Thanks for the feedback @dscho! I'll submit this next week, but if you have any further feedback in the meantime I'd appreciate it! |
@@ -658,6 +658,38 @@ void clear_exclude_list(struct exclude_list *el) | |||
memset(el, 0, sizeof(*el)); | |||
} | |||
|
|||
static void trim_trailing_comments(char *buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is very similar to trim_trailing_spaces()
. l don't think logic should be put at all costs in one single function, but it's worth thinking if they can be merged somehow.
@cbzehner gentle ping? |
Thanks for the reminder @dscho. I'll get this updated and out this week. |
Signed-off-by: Chris Zehner <cbzehner@gmail.com>
Updated onto the latest master branch and opened a PR on GitGitGadget gitgitgadget#370 Should I leave this PR open in the meantime or close this and continue my submission via gitgitgadget#370? |
My personal preference would be to close it here, as I am trying to reduce the number of PRs in https://github.com/git/git/pulls (so I regularly look through many open PRs here). |
Sounds good. Thank you for your guidance! |
Why make this change?
Add the ability to use
#
to put comments after ignore patterns. This isuseful for documenting the reason for particular ignore patterns inclusion
and structure.
Right now a common convention in
.gitignore
files is to group patternsby similarity using new lines beginning with one or more
#
charactersas headings.
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?
Any part of a string after a non-escaped
#
, including the#
, is removedfrom the pattern.
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
removesextraneous spaces from patterns.
How can we test this change works?
That's one area I'd like help with, please.
Test cases:
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. Wouldsomeone be willing to provide a pointer to the correct place to add these tests?
Signed-off-by: Chris Zehner cbzehner@gmail.com