From a83123deecfdd5078c2e16166576fb17add194b2 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Bj=C3=B6rn=20Steinbrink?= <B.Steinbrink@gmx.de>
Date: Fri, 6 Jun 2008 01:31:55 +0200
Subject: [PATCH] name-rev: Fix segmentation fault when using --all
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

In commit da2478db "describe --always: fall back to showing an
abbreviated object name" we lost the check that skips empty entries in
the object hash table when iterating over it in cmd_name_rev. That may
cause a NULL pointer being handed to show_name(), leading to a
segmentation fault. So add that check back again.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-name-rev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 384da4db13..521f061c9e 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -280,9 +280,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 		int i, max;
 
 		max = get_max_object_index();
-		for (i = 0; i < max; i++)
-			show_name(get_indexed_object(i), NULL,
+		for (i = 0; i < max; i++) {
+			struct object *obj = get_indexed_object(i);
+			if (!obj)
+				continue;
+			show_name(obj, NULL,
 				  always, allow_undefined, data.name_only);
+		}
 	} else {
 		int i;
 		for (i = 0; i < revs.nr; i++)
-- 
2.40.0