summaryrefslogtreecommitdiffstats
path: root/t/t3301-notes.sh
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2024-07-29 17:14:00 +0200
committerJunio C Hamano <gitster@pobox.com>2024-07-30 00:31:30 +0200
commit8b426c84f376657e1e10839f3f5dafd9ba99593d (patch)
tree4448823eabf18b01a060808ddf71a7ed15ef95c3 /t/t3301-notes.sh
parentGit 2.46 (diff)
downloadgit-8b426c84f376657e1e10839f3f5dafd9ba99593d.tar.xz
git-8b426c84f376657e1e10839f3f5dafd9ba99593d.zip
notes: do not trigger editor when adding an empty note
With "git notes add -C $blob", the given blob contents are to be made into a note without involving an editor. But when "--allow-empty" is given, the editor is invoked, which can cause problems for non-interactive callers[1]. This behaviour started with 90bc19b3ae (notes.c: introduce '--separator=<paragraph-break>' option, 2023-05-27), which changed editor invocation logic to check for a zero length note_data buffer. Restore the original behaviour of "git note" that takes the contents given via the "-m", "-C", "-F" options without invoking an editor, by checking for any prior parameter callbacks, indicated by a non-zero note_data.msg_nr. Remove the now-unneeded note_data.given flag. Add a test for this regression by checking whether GIT_EDITOR is invoked alongside "git notes add -C $empty_blob --allow-empty" [1] https://github.com/ddiss/icyci/issues/12 Signed-off-by: David Disseldorp <ddiss@suse.de> [jc: enhanced the test with -m/-F options] Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rwxr-xr-xt/t3301-notes.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 536bd11ff4..99137fb235 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -1557,4 +1557,14 @@ test_expect_success 'empty notes are displayed by git log' '
test_cmp expect actual
'
+test_expect_success 'empty notes do not invoke the editor' '
+ test_commit 18th &&
+ GIT_EDITOR="false" git notes add -C "$empty_blob" --allow-empty &&
+ git notes remove HEAD &&
+ GIT_EDITOR="false" git notes add -m "" --allow-empty &&
+ git notes remove HEAD &&
+ GIT_EDITOR="false" git notes add -F /dev/null --allow-empty &&
+ git notes remove HEAD
+'
+
test_done