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

Re: [PATCH] Make find_commit_subject() more robust

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 22, 2016, 09:03 UTC
Message-ID
<alpine.DEB.2.20.1606221041320.10382@virtualbox>
In-Reply-To
<xmqqziqent0e.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Tue, 21 Jun 2016, Junio C Hamano wrote:
Show 16 quoted lines
> Your patch introduces a similar loop with similar (but different)
> purpose:
> 
> 		while (*p == '\n')
> 			p++;
> 
> which would have been helped if there were a helper with an
> opposite function, i.e.
> 
> 		p = strcchrnul(p, '\n');
> 
> i.e. "give me the pointer to the first byte that is not '\n', or EOS".
> 
> But there is no such thing.  Although p += strcspn(p, "\n") is a
> possibility, that somehow feels a bit odd.  And that is why I did
> not hint any existing function and said "might want to find".

Sure. And strcspn() is less efficient than the loop if you already know that the second parameter contains only a single character.

Show 8 quoted lines
> HOWEVER.
> 
> Stepping back a bit, I think what we actually want is
> 
> 		p = skip_blank_lines(p);
> 
> that skips any and all blank lines, including an empty line that
> consists of all whitespace.

My original aim was to make find_commit_subject() consistent with the pretty-printing machinery. I failed to realize that skip_blank_lines() does more than skipping empty lines, so let me re-roll the patch.

Ciao, Dscho

Previous: Junio C HamanoNext: Johannes Schindelin
Message 5 of 15 in “Make find_commit_subject() more robust”
  1. Make find_commit_subject() more robustJohannes Schindelin, Jun 18, 2016
  2. Junio C HamanoJun 20, 2016
  3. Johannes SchindelinJun 21, 2016
  4. Junio C HamanoJun 21, 2016
  5. Johannes SchindelinJun 22, 2016
  6. Make find_commit_subject() more robustJohannes Schindelin, Jun 21, 2016
  7. Junio C HamanoJun 21, 2016
  8. 0/2 Make find_commit_subject() consistent with --format=%sJohannes Schindelin, Jun 22, 2016
  9. 2/2 Make find_commit_subject() more robustJohannes Schindelin, Jun 22, 2016
  10. 1/2 Make the skip_empty_lines() function publicJohannes Schindelin, Jun 22, 2016
  11. Junio C HamanoJun 22, 2016
  12. Johannes SchindelinJun 22, 2016
  13. 0/2 Make find_commit_subject() consistent with --format=%sJohannes Schindelin, Jun 22, 2016
  14. 1/2 Make the skip_blank_lines() function publicJohannes Schindelin, Jun 22, 2016
  15. 2/2 Make find_commit_subject() more robustJohannes Schindelin, Jun 22, 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.