Skip to content

Commit 531e758

Browse files
kusmagitster
authored andcommitted
ls: remove redundant logic
find_unique_abbrev() already returns the full SHA-1 if abbrev = 0, so we can remove the logic that avoids the call. Signed-off-by: Erik Faye-Lund <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28a5317 commit 531e758

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

builtin/ls-files.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
153153
printf("%s%06o %s %d\t",
154154
tag,
155155
ce->ce_mode,
156-
abbrev ? find_unique_abbrev(ce->sha1,abbrev)
157-
: sha1_to_hex(ce->sha1),
156+
find_unique_abbrev(ce->sha1,abbrev),
158157
ce_stage(ce));
159158
}
160159
write_name_quoted(ce->name + offset, stdout, line_terminator);
@@ -176,9 +175,7 @@ static int show_one_ru(struct string_list_item *item, void *cbdata)
176175
if (!ui->mode[i])
177176
continue;
178177
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
179-
abbrev
180-
? find_unique_abbrev(ui->sha1[i], abbrev)
181-
: sha1_to_hex(ui->sha1[i]),
178+
find_unique_abbrev(ui->sha1[i], abbrev),
182179
i + 1);
183180
write_name_quoted(path + offset, stdout, line_terminator);
184181
}

builtin/ls-tree.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
103103
} else
104104
strcpy(size_text, "-");
105105
printf("%06o %s %s %7s\t", mode, type,
106-
abbrev ? find_unique_abbrev(sha1, abbrev)
107-
: sha1_to_hex(sha1),
106+
find_unique_abbrev(sha1, abbrev),
108107
size_text);
109108
} else
110109
printf("%06o %s %s\t", mode, type,
111-
abbrev ? find_unique_abbrev(sha1, abbrev)
112-
: sha1_to_hex(sha1));
110+
find_unique_abbrev(sha1, abbrev));
113111
}
114112
write_name_quotedpfx(base + chomp_prefix, baselen - chomp_prefix,
115113
pathname, stdout, line_termination);

0 commit comments

Comments
 (0)