git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix `git rev-list --show-notes HEAD` when there are no notes
@ 2015-08-22 15:14 Johannes Schindelin
  2015-08-22 16:30 ` Johan Herland
  2015-08-23 17:43 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Schindelin @ 2015-08-22 15:14 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-08-24 14:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-22 15:14 [PATCH] Fix `git rev-list --show-notes HEAD` when there are no notes Johannes Schindelin
2015-08-22 16:30 ` Johan Herland
2015-08-23 17:43 ` Jeff King
2015-08-23 17:56   ` [PATCH] rev-list: make it obvious that we do not support notes Jeff King
2015-08-24 10:23   ` [PATCH] Fix `git rev-list --show-notes HEAD` when there are no notes Johannes Schindelin
2015-08-24 14:43     ` Jeff King
2015-08-24 14:48       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).