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

Re: [PATCH 5/5] Skip blank lines when matching <commit>^{/foo}

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2016, 22:53 UTC
Message-ID
<xmqqh9cb1ub0.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<7cebdcd80a93d1604258e9dc9cb286cd6ba97ba8.1467209576.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 7 quoted lines
> When trying to match a pattern in the commit subject, simply skip leading
> blank lines in the commit message. This is consistent with the
> pretty-printing machinery: it silently ignores leading blank lines in the
> commit object's body.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
Hmm.
I just tried
    $ git commit -s -m '  pull: fast-forward "pull --rebase=true"'
expecting that ":/^  pull:" would find it ;-)

The point of this patch is to make it not work, of course, which may or may not be a good thing. I'd rather keep this separate from the other fixes.

Also 4/5 is another different class of true bugfix, I would suspect, so let's take it on a separate topic that can be merged down to older maintainance tracks.

Thanks.
Show 17 quoted lines
>  sha1_name.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index ca7ddd6..da354a5 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -912,7 +912,8 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1,
>  			continue;
>  		buf = get_commit_buffer(commit, NULL);
>  		p = strstr(buf, "\n\n");
> -		matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
> +		matches = negative ^ (p && !regexec(&regex,
> +			skip_blank_lines(p + 2), 0, NULL, 0));
>  		unuse_commit_buffer(commit, buf);
>  
>  		if (matches) {
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 of 11 in “Use skip_blank_lines() for more commit messages”
  1. 0/5 Use skip_blank_lines() for more commit messagesJohannes Schindelin, Jun 29, 2016
  2. 1/5 commit -C: skip blank lines at the beginning of the messageJohannes Schindelin, Jun 29, 2016
  3. Junio C HamanoJun 29, 2016
  4. 2/5 sequencer: use skip_blank_lines() to find the commit subjectJohannes Schindelin, Jun 29, 2016
  5. Junio C HamanoJun 29, 2016
  6. 3/5 reset --hard: skip blank lines when reporting the commit subjectJohannes Schindelin, Jun 29, 2016
  7. 4/5 commit -S: avoid invalid pointer with empty messageJohannes Schindelin, Jun 29, 2016
  8. 5/5 Skip blank lines when matching <commit>^{/foo}Johannes Schindelin, Jun 29, 2016
  9. Junio C HamanoJun 29, 2016
  10. Johannes SchindelinJul 2, 2016
  11. Junio C HamanoJun 29, 2016

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.