Skip to content

Commit 9b144d8

Browse files
committed
Merge branch 'jh/empty-notes'
A request to store an empty note via "git notes" meant to remove note from the object but with --allow-empty we will store a (surprise!) note that is empty. In the longer run, we might want to deprecate the somewhat unintuitive "emptying means deletion" behaviour. * jh/empty-notes: t3301: modernize style notes: empty notes should be shown by 'git log' builtin/notes: add --allow-empty, to allow storing empty notes builtin/notes: split create_note() to clarify add vs. remove logic builtin/notes: simplify early exit code in add() builtin/notes: refactor note file path into struct note_data builtin/notes: improve naming t3301: verify that 'git notes' removes empty notes by default builtin/notes: fix premature failure when trying to add the empty blob
2 parents 7f2186c + 908a320 commit 9b144d8

File tree

4 files changed

+789
-825
lines changed

4 files changed

+789
-825
lines changed

Documentation/git-notes.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git notes' [list [<object>]]
12-
'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
12+
'git notes' add [-f] [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
1313
'git notes' copy [-f] ( --stdin | <from-object> <to-object> )
14-
'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
15-
'git notes' edit [<object>]
14+
'git notes' append [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
15+
'git notes' edit [--allow-empty] [<object>]
1616
'git notes' show [<object>]
1717
'git notes' merge [-v | -q] [-s <strategy> ] <notes-ref>
1818
'git notes' merge --commit [-v | -q]
@@ -155,6 +155,10 @@ OPTIONS
155155
Like '-C', but with '-c' the editor is invoked, so that
156156
the user can further edit the note message.
157157

158+
--allow-empty::
159+
Allow an empty note object to be stored. The default behavior is
160+
to automatically remove empty notes.
161+
158162
--ref <ref>::
159163
Manipulate the notes tree in <ref>. This overrides
160164
'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
@@ -287,7 +291,7 @@ arbitrary files using 'git hash-object':
287291
------------
288292
$ cc *.c
289293
$ blob=$(git hash-object -w a.out)
290-
$ git notes --ref=built add -C "$blob" HEAD
294+
$ git notes --ref=built add --allow-empty -C "$blob" HEAD
291295
------------
292296

293297
(You cannot simply use `git notes --ref=built add -F a.out HEAD`

0 commit comments

Comments
 (0)