Produce a nicer output in case of sha1_object_info failures in ls-tree -l
An error message is already printed by sha1_object_info itself, and the failed entries are additionally marked in the listing. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6872f606d9
commit
e392a85236
@ -60,7 +60,6 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
|
|||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
const char *type = blob_type;
|
const char *type = blob_type;
|
||||||
unsigned long size;
|
|
||||||
|
|
||||||
if (S_ISGITLINK(mode)) {
|
if (S_ISGITLINK(mode)) {
|
||||||
/*
|
/*
|
||||||
@ -90,17 +89,20 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
|
|||||||
|
|
||||||
if (!(ls_options & LS_NAME_ONLY)) {
|
if (!(ls_options & LS_NAME_ONLY)) {
|
||||||
if (ls_options & LS_SHOW_SIZE) {
|
if (ls_options & LS_SHOW_SIZE) {
|
||||||
|
char size_text[24];
|
||||||
if (!strcmp(type, blob_type)) {
|
if (!strcmp(type, blob_type)) {
|
||||||
sha1_object_info(sha1, &size);
|
unsigned long size;
|
||||||
printf("%06o %s %s %7lu\t", mode, type,
|
if (sha1_object_info(sha1, &size) == OBJ_BAD)
|
||||||
abbrev ? find_unique_abbrev(sha1, abbrev)
|
strcpy(size_text, "BAD");
|
||||||
: sha1_to_hex(sha1),
|
else
|
||||||
size);
|
snprintf(size_text, sizeof(size_text),
|
||||||
|
"%lu", size);
|
||||||
} else
|
} else
|
||||||
printf("%06o %s %s %7c\t", mode, type,
|
strcpy(size_text, "-");
|
||||||
abbrev ? find_unique_abbrev(sha1, abbrev)
|
printf("%06o %s %s %7s\t", mode, type,
|
||||||
: sha1_to_hex(sha1),
|
abbrev ? find_unique_abbrev(sha1, abbrev)
|
||||||
'-');
|
: sha1_to_hex(sha1),
|
||||||
|
size_text);
|
||||||
} else
|
} else
|
||||||
printf("%06o %s %s\t", mode, type,
|
printf("%06o %s %s\t", mode, type,
|
||||||
abbrev ? find_unique_abbrev(sha1, abbrev)
|
abbrev ? find_unique_abbrev(sha1, abbrev)
|
||||||
|
Loading…
Reference in New Issue
Block a user