name-rev: Fix segmentation fault when using --all

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>
This commit is contained in:
Björn Steinbrink 2008-06-06 01:31:55 +02:00 коммит произвёл Junio C Hamano
Родитель 4ed19a3c17
Коммит a83123deec
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -280,9 +280,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
int i, max; int i, max;
max = get_max_object_index(); max = get_max_object_index();
for (i = 0; i < max; i++) for (i = 0; i < max; i++) {
show_name(get_indexed_object(i), NULL, struct object *obj = get_indexed_object(i);
if (!obj)
continue;
show_name(obj, NULL,
always, allow_undefined, data.name_only); always, allow_undefined, data.name_only);
}
} else { } else {
int i; int i;
for (i = 0; i < revs.nr; i++) for (i = 0; i < revs.nr; i++)