notes.c: introduce '--separator=<paragraph-break>' option
commit90bc19b3aede4ebe8b1044541373ac970804cde4
authorTeng Long <dyroneteng@gmail.com>
Sat, 27 May 2023 07:57:51 +0000 (27 15:57 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Jun 2023 15:51:00 +0000 (21 08:51 -0700)
treec85e4aa55e1c37a009d81fcd28ce3784cd2ddecc
parent59587049e2724d762c52f8c475e7ecd79dc96b18
notes.c: introduce '--separator=<paragraph-break>' option

When adding new notes or appending to an existing notes, we will
insert a blank line between the paragraphs, like:

     $ git notes add -m foo -m bar
     $ git notes show HEAD
     foo

     bar

The default behavour sometimes is not enough, the user may want
to use a custom delimiter between paragraphs, like when
specifying '-m', '-F', '-C', '-c' options. So this commit
introduce a new '--separator' option for 'git notes add' and
'git notes append', for example when executing:

    $ git notes add -m foo -m bar --separator="-"
    $ git notes show HEAD
    foo
    -
    bar

a newline is added to the value given to --separator if it
does not end with one already. So when executing:

      $ git notes add -m foo -m bar --separator="-"
and
      $ export LF="
      "
      $ git notes add -m foo -m bar --separator="-$LF"

Both the two exections produce the same result.

The reason we use a "strbuf" array to concat but not "string_list", is
that the binary file content may contain '\0' in the middle, this will
cause the corrupt result if using a string to save.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-notes.txt
builtin/notes.c
t/t3301-notes.sh