diff options
| author | Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> | 2024-10-21 18:12:20 +0000 |
|---|---|---|
| committer | Taylor Blau <me@ttaylorr.com> | 2024-10-21 15:52:48 -0400 |
| commit | dab0b9e176d64f7687029b176d96eddfbf74db64 (patch) | |
| tree | acf1be4f525845907cc2d842c476af4b5267b53a /t | |
| parent | 34b6ce9b30747131b6e781ff718a45328aa887d0 (diff) | |
| download | git-dab0b9e176d64f7687029b176d96eddfbf74db64.tar.gz | |
notes: teach the -e option to edit messages in editor
Notes can be added to a commit using:
- "-m" to provide a message on the command line.
- -C to copy a note from a blob object.
- -F to read the note from a file.
When these options are used, Git does not open an editor,
it simply takes the content provided via these options and
attaches it to the commit as a note.
Improve flexibility to fine-tune the note before finalizing it
by allowing the messages to be prefilled in the editor and edited
after the messages have been provided through -[mF].
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 't')
| -rwxr-xr-x | t/t3301-notes.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index 99137fb235..813dfd8db9 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -1567,4 +1567,67 @@ 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 && + echo "edited" >expect && + MSG="$(cat expect)" git notes add -m "initial" -e && + git notes show >actual && + test_cmp expect actual && + git notes remove HEAD && + + # Add a note using -F and edit it + echo "initial" >note_file && + MSG="$(cat expect)" git notes add -F note_file -e && + git notes show >actual && + test_cmp expect actual +' + +test_expect_success 'git notes append with -m/-F invokes the editor with -e' ' + test_commit 20th && + cat >expect <<-EOF && + initial + + edited + EOF + git notes add -m "initial" && + MSG="edited" git notes append -m "appended" -e && + + # Verify the note content was appended and edited + git notes show >actual && + test_cmp expect actual && + git notes remove HEAD && + + # Append a note using -F and edit it + echo "note from file" >note_file && + git notes add -m "initial" && + MSG="edited" git notes append -F note_file -e && + + # Verify notes from file has been edited in editor and appended + 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 && + echo "edited" >expect && + + MSG=$(cat expect) git notes append -F note_1 -m "message-1" -F note_2 -e && + + # Verify that combined messages from file and -m have been edited + git notes show >actual && + test_cmp expect actual +' +test_expect_success 'git notes append aborts when editor fails with -e' ' + test_commit 22nd && + echo "foo-file-1" >note_1 && + + # Try to append a note with -F and -e, but make the editor fail + test_env GIT_EDITOR="false" test_must_fail git notes append -F note_1 -e && + + # Verify that no note was added due to editor failure + test_must_fail git notes show +' + test_done |
