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

[PATCH v4 0/7] replacing strbuf_getline_lf() by strbuf_getline()

From
MNMoritz Neeb <lists@moritzneeb.de>
Date
Feb 29, 2016, 08:30 UTC
Message-ID
<56D401C2.8020100@moritzneeb.de>
In-Reply-To
<56D28092.9090209@moritzneeb.de>

Although I was not sure [4], I decided to roll out v4, in the hope that the next reviewers will profit by the more polished commit messages and order.

This series deals with strbuf_getline_lf() in certain codepaths: Those, where the input that is read, is/was trimmed before doing anything that could possibly expect a CR character. Those places can be assumed to be "text" input, where a CR never would be a meaningful control character.

The purpose of this series is to document these places to have this property, by using strbuf_getline() instead of strbuf_getline_lf(). Also in some codepaths, the CR could be a leftover of an editor and is thus removed.

Every codepath was examined, if after the change it is still necessary to have trimming or if the additional CRLF-removal suffices.

The series is an idea out of [1], where Junio proposed to replace the calls to strbuf_getline_lf() because it 'would [be] a good way to document them as dealing with "text"'.

Changes since v3 [3] (the changes to single patches are indicated below):
 * Commit messages refined
 * Order of patch 4 and 5 in v2 was switched.

The interdiff only removes an empty line (I noticed, when changing the order of commits, that the splitting operation had no newline before this whole series, so I left it that way):

diff --git a/builtin/notes.c b/builtin/notes.c
index 660c0b7..715fade 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -296,7 +296,6 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
         int err;
 
         string_list_split(&split, buf.buf, ' ', -1);
-
         if (split.nr != 2)
             die(_("Malformed input line: '%s'."), buf.buf);
         if (get_sha1(split.items[0].string, from_obj))

-Moritz

[1], idea: http://thread.gmane.org/gmane.comp.version-control.git/284104
[2], v2: http://thread.gmane.org/gmane.comp.version-control.git/285118/focus=286865
[3], v3: http://thread.gmane.org/gmane.comp.version-control.git/285118/focus=287747
[4] http://thread.gmane.org/gmane.comp.version-control.git/285118/focus=287760

Moritz Neeb (7):
  quote: remove leading space in sq_dequote_step -- as in v2
  bisect: read bisect paths with strbuf_getline() -- refined commit message
  clean: read user input with strbuf_getline() -- simplified commit message
  notes copy --stdin: read lines with strbuf_getline() -- switched with below
  notes copy --stdin: split lines with string_list_split() -- switched with above
  remote: read $GIT_DIR/branches/* with strbuf_getline() -- as in v3
  wt-status: read rebase todolist with strbuf_getline() -- as in v2

 bisect.c        |  5 ++---
 builtin/clean.c |  6 +++---
 builtin/notes.c | 22 ++++++++++------------
 quote.c         |  2 ++
 remote.c        |  2 +-
 wt-status.c     |  3 +--
 6 files changed, 19 insertions(+), 21 deletions(-)
-- 
2.4.3
Previous: Moritz NeebNext: Moritz Neeb
Message 19 of 38 in “replacing strbuf_getline_lf() by strbuf_getline()”
  1. 0/7 replacing strbuf_getline_lf() by strbuf_getline()Moritz Neeb, Feb 28, 2016
  2. 1/7 quote: remove leading space in sq_dequote_stepMoritz Neeb, Feb 28, 2016
  3. 2/7 bisect: read bisect paths with strbuf_getline()Moritz Neeb, Feb 28, 2016
  4. Eric SunshineFeb 28, 2016
  5. Moritz NeebFeb 28, 2016
  6. 3/7 clean: read user input with strbuf_getline()Moritz Neeb, Feb 28, 2016
  7. Eric SunshineFeb 28, 2016
  8. Moritz NeebFeb 28, 2016
  9. 4/7 notes copy --stdin: split lines with string_list_split()Moritz Neeb, Feb 28, 2016
  10. Eric SunshineFeb 28, 2016
  11. Moritz NeebFeb 28, 2016
  12. Eric SunshineFeb 28, 2016
  13. 5/7 notes copy --stdin: read lines with strbuf_getline()Moritz Neeb, Feb 28, 2016
  14. 6/7 remote: read $GIT_DIR/branches/* with strbuf_getline()Moritz Neeb, Feb 28, 2016
  15. 7/7 wt-status: read rebase todolist with strbuf_getline()Moritz Neeb, Feb 28, 2016
  16. Eric SunshineFeb 28, 2016
  17. Moritz NeebFeb 28, 2016
  18. Moritz NeebFeb 28, 2016
  19. 0/7 replacing strbuf_getline_lf() by strbuf_getline()Moritz Neeb, Feb 29, 2016
  20. 1/7 quote: remove leading space in sq_dequote_stepMoritz Neeb, Feb 29, 2016
  21. Junio C HamanoFeb 29, 2016
  22. Moritz NeebFeb 29, 2016
  23. Moritz NeebFeb 29, 2016
  24. 2/7 bisect: read bisect paths with strbuf_getline()Moritz Neeb, Feb 29, 2016
  25. 3/7 clean: read user input with strbuf_getline()Moritz Neeb, Feb 29, 2016
  26. 5/7 notes copy --stdin: split lines with string_list_split()Moritz Neeb, Feb 29, 2016
  27. 6/7 remote: read $GIT_DIR/branches/* with strbuf_getline()Moritz Neeb, Feb 29, 2016
  28. 7/7 wt-status: read rebase todolist with strbuf_getline()Moritz Neeb, Feb 29, 2016
  29. 4/7 notes copy --stdin: read lines with strbuf_getline()Moritz Neeb, Feb 29, 2016
  30. Eric SunshineFeb 29, 2016
  31. Moritz NeebFeb 29, 2016
  32. Eric SunshineFeb 29, 2016
  33. Eric SunshineFeb 29, 2016
  34. Moritz NeebMar 9, 2016
  35. Junio C HamanoMar 9, 2016
  36. Moritz NeebMar 9, 2016
  37. Junio C HamanoMar 9, 2016
  38. Eric SunshineMar 9, 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.