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

Re: [PATCH v9 4/6] notes.c: introduce '--separator=<paragraph-break>' option

From
Junio C Hamano <gitster@pobox.com>
Date
May 16, 2023, 17:00 UTC
Message-ID
<xmqqttwcus7p.fsf@gitster.g>
In-Reply-To
<20230512040746.2069-1-tenglong.tl@alibaba-inc.com>
Teng Long <dyroneteng@gmail.com> writes:
Show 5 quoted lines
> Returning to the issue of -separator = "", my thought is that I want
> --separator="" to behave the same way as
> --separator="<any-string-without-a-trailing-\n'>" when deals a string which does
> not contains a trailing newline. This will eliminate one more implicit logic and
> make behavior more consistent.

An obvious alternative would be to use the string given to the "--separator" option literally, I guess, and you can add your own newline if you want to. But most of the time you would not want to have an incomplete line, so appending the newline at the end by default does make sense.

Special casing an empty value to "--separator" as "nothing" does make sort-of sense. Using a blank line as the inter-paragraph separator is the default, and there is not much use in the "--separator=''" that becomes "--separator=$'\012'" automatically.

> I think --no-separator maybe a better name, means that not any separator will be
> append between two paragraphs even a newline.

It would work as well. Is it something we can safely add before merging the topic to upcoming -rc1?

Thanks.
Previous: Kristoffer HaugsbakkNext: Teng Long
Message 12 of 55 in “notes.c: introduce "--separator" option”
  1. 0/6 notes.c: introduce "--separator" optionTeng Long, Apr 28, 2023
  2. 1/6 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, Apr 28, 2023
  3. 2/6 notes.c: use designated initializers for clarityTeng Long, Apr 28, 2023
  4. 3/6 t3321: add test cases about the notes stripspace behaviorTeng Long, Apr 28, 2023
  5. 4/6 notes.c: introduce '--separator=<paragraph-break>' optionTeng Long, Apr 28, 2023
  6. Junio C HamanoApr 28, 2023
  7. Teng LongMay 6, 2023
  8. Teng LongMay 6, 2023
  9. Kristoffer HaugsbakkMay 10, 2023
  10. Teng LongMay 12, 2023
  11. Kristoffer HaugsbakkMay 12, 2023
  12. Junio C HamanoMay 16, 2023
  13. Teng LongMay 17, 2023
  14. Junio C HamanoMay 17, 2023
  15. Junio C HamanoJun 14, 2023
  16. notes: do not access before the beginning of an arrayJunio C Hamano, Jun 14, 2023
  17. Eric SunshineJun 14, 2023
  18. Junio C HamanoJun 14, 2023
  19. Jeff KingJun 15, 2023
  20. Junio C HamanoJun 15, 2023
  21. Teng LongJun 19, 2023
  22. Junio C HamanoJun 20, 2023
  23. Teng LongJun 21, 2023
  24. 5/6 notes.c: append separator instead of insert by posTeng Long, Apr 28, 2023
  25. 6/6 notes.c: introduce "--[no-]stripspace" optionTeng Long, Apr 28, 2023
  26. Junio C HamanoApr 28, 2023
  27. Junio C HamanoMay 1, 2023
  28. 0/6 notes.c: introduce "--separator" optionTeng Long, May 18, 2023
  29. 1/6 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, May 18, 2023
  30. 2/6 notes.c: use designated initializers for clarityTeng Long, May 18, 2023
  31. 3/6 t3321: add test cases about the notes stripspace behaviorTeng Long, May 18, 2023
  32. 5/6 notes.c: append separator instead of insert by posTeng Long, May 18, 2023
  33. 4/6 notes.c: introduce '[--[no-]separator|--separator=<paragraph-break>]' optionTeng Long, May 18, 2023
  34. Kristoffer HaugsbakkMay 18, 2023
  35. Teng LongMay 20, 2023
  36. Kristoffer HaugsbakkMay 20, 2023
  37. Jeff KingMay 19, 2023
  38. Teng LongMay 27, 2023
  39. Jeff KingMay 27, 2023
  40. Teng LongMay 29, 2023
  41. 6/6 notes.c: introduce "--[no-]stripspace" optionTeng Long, May 18, 2023
  42. Kristoffer HaugsbakkMay 18, 2023
  43. Teng LongMay 20, 2023
  44. Junio C HamanoMay 18, 2023
  45. Teng LongMay 20, 2023
  46. 0/7 notes.c: introduce "--separator"Teng Long, May 27, 2023
  47. 1/7 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, May 27, 2023
  48. 2/7 notes.c: use designated initializers for clarityTeng Long, May 27, 2023
  49. 3/7 t3321: add test cases about the notes stripspace behaviorTeng Long, May 27, 2023
  50. 4/7 notes.c: introduce '--separator=<paragraph-break>' optionTeng Long, May 27, 2023
  51. 5/7 notes.c: append separator instead of insert by posTeng Long, May 27, 2023
  52. 6/7 notes.c: introduce "--[no-]stripspace" optionTeng Long, May 27, 2023
  53. 7/7 notes: introduce "--no-separator" optionTeng Long, May 27, 2023
  54. Junio C HamanoJun 1, 2023
  55. Teng LongJun 3, 2023

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.