Show 129 quoted lines
>
> > diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
> > index c9221a68cce..d5505a426aa 100644
> > --- a/Documentation/git-notes.txt
> > +++ b/Documentation/git-notes.txt
> > @@ -9,9 +9,9 @@ SYNOPSIS
> > --------
> > [verse]
> > 'git notes' [list [<object>]]
> > -'git notes' add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
> > +'git notes' add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] [-e]
> > 'git notes' copy [-f] ( --stdin | <from-object> [<to-object>] )
> > -'git notes' append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
> > +'git notes' append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] [-e]
> > 'git notes' edit [--allow-empty] [<object>] [--[no-]stripspace]
> > 'git notes' show [<object>]
> > 'git notes' merge [-v | -q] [-s <strategy> ] <notes-ref>
>
> Nit: I'd move the `[-e]` before [<object>] so that -F, -C and -m are all
> close together.
>
> > diff --git a/builtin/notes.c b/builtin/notes.c
> > index 8c26e455269..72c8a51cfac 100644
> > --- a/builtin/notes.c
> > +++ b/builtin/notes.c
> > @@ -489,6 +489,8 @@ static int add(int argc, const char **argv, const char *prefix)
> > OPT_CALLBACK_F('c', "reedit-message", &d, N_("object"),
> > N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
> > parse_reedit_arg),
> > + OPT_BOOL('e', "edit", &d.use_editor,
> > + N_("edit note message in editor")),
> > OPT_CALLBACK_F('C', "reuse-message", &d, N_("object"),
> > N_("reuse specified note object"), PARSE_OPT_NONEG,
> > parse_reuse_arg),
> > @@ -667,6 +669,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
> > OPT_CALLBACK_F('C', "reuse-message", &d, N_("object"),
> > N_("reuse specified note object"), PARSE_OPT_NONEG,
> > parse_reuse_arg),
> > + OPT_BOOL('e', "edit", &d.use_editor,
> > + N_("edit note message in editor")),
> > OPT_BOOL(0, "allow-empty", &allow_empty,
> > N_("allow storing empty note")),
> > OPT_CALLBACK_F(0, "separator", &separator,
>
> Nice.
>
> > diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
> > index 99137fb2357..ffa1d21671d 100755
> > --- a/t/t3301-notes.sh
> > +++ b/t/t3301-notes.sh
> > @@ -1567,4 +1567,60 @@ test_expect_success 'empty notes do not invoke the editor' '
> > git notes remove HEAD
> > '
> >
> > +test_expect_success 'git notes add with -m/-F invokes editor with -e' '
> > + test_commit 19th &&
> > + MSG="Edited notes message" git notes add -m "Initial notes message" -e &&
> > + echo "Edited notes message" >expect &&
> > + git notes show >actual &&
> > + test_cmp expect actual &&
> > + git notes remove HEAD &&
> > +
> > + # Add a note using -F and edit it
> > + echo "Note from file" >note_file &&
> > + MSG="Edited note from file" git notes add -F note_file -e &&
> > + echo "Edited note from file" >expect &&
> > + git notes show >actual &&
> > + test_cmp expect actual
> > +'
>
> I was surprised at first why the MSG ended up in the commit message. But
> the setup of t3301 writes a fake editor that listens to this environment
> variable, so this looks good to me.
>
> > +test_expect_success 'git notes append with -m/-F invokes the editor with -e' '
> > + test_commit 20th &&
> > + git notes add -m "Initial note message" &&
> > + MSG="Appended edited note message" git notes append -m "New appended note" -e &&
> > +
> > + # Verify the note content was appended and edited
> > + echo "Initial note message" >expect &&
> > + echo "" >>expect &&
> > + echo "Appended edited note message" >>expect &&
>
> When you want to write multiple lines we typically use HERE docs. E.g.:
>
> cat >expect <<-EOF &&
> Initial note message
>
> Appended edited note message
> EOF
>
> > + git notes show >actual &&
> > + test_cmp expect actual &&
> > + git notes remove HEAD &&
> > +
> > + #Append a note using -F and edit it
>
> There should be a space after the "#" here.
>
> > + echo "Note from file" >note_file &&
> > + git notes add -m "Initial note message" &&
> > + MSG="Appended edited note from file" git notes append -F note_file -e &&
> > +
> > + # Verify notes from file has been edited in editor and appended
> > + echo "Initial note message" >expect &&
> > + echo "" >>expect &&
> > + echo "Appended edited note from file" >>expect &&
>
> Same comment here.
>
> > + git notes show >actual &&
> > + test_cmp expect actual
> > +'
> > +
> > +test_expect_success 'git notes with a combination of -m, -F and -e invokes editor' '
> > + test_commit 21st &&
> > + echo "foo-file-1" >note_1 &&
> > + echo "foo-file-2" >note_2 &&
> > +
> > + MSG="Collapsed edited notes" git notes append -F note_1 -m "message-1" -F note_2 -e &&
> > +
> > + # Verify that combined messages from file and -m have been edited
> > +
> > + echo "Collapsed edited notes" >expect &&
> > + git notes show >actual &&
> > + test_cmp expect actual
> > +'
> > +