[PATCH] Fix `git rev-list --show-notes HEAD` when there are no notes
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 22, 2015, 15:14 UTC
- Message-ID
- <0LZlZ2-1Z1Zyn1mzk-00lZ3Z@mail.gmx.com>
The `format_display_notes()` function clearly assumes that the data structure holding the notes has been initialized already, i.e. that the `display_notes_trees` variable is no longer `NULL`.
However, when there are no notes whatsoever, this variable is still `NULL`, even after initialization.
So let's be graceful and just return if that data structure is `NULL`.
Reported in https://github.com/msysgit/git/issues/363.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- notes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/notes.c b/notes.c index df08209..24a335a 100644 --- a/notes.c +++ b/notes.c @@ -1266,7 +1266,10 @@ void format_display_notes(const unsigned char *object_sha1, struct strbuf *sb, const char *output_encoding, int raw) { int i; - assert(display_notes_trees); + + if (!display_notes_trees) + return; + for (i = 0; display_notes_trees[i]; i++) format_note(display_notes_trees[i], object_sha1, sb, output_encoding, raw);
-- 2.3.1.windows.1.9.g8c01ab4