Skip to content

Commit 5306ccf

Browse files
bmwillgitster
authored andcommitted
ls-files: factor out debug info into a function
Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f587c8d commit 5306ccf

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

builtin/ls-files.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ static void write_name(const char *name)
9393
strbuf_release(&full_name);
9494
}
9595

96+
static void print_debug(const struct cache_entry *ce)
97+
{
98+
if (debug_mode) {
99+
const struct stat_data *sd = &ce->ce_stat_data;
100+
101+
printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
102+
printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
103+
printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
104+
printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
105+
printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
106+
}
107+
}
108+
96109
static void show_dir_entry(const char *tag, struct dir_entry *ent)
97110
{
98111
int len = max_prefix_len;
@@ -279,15 +292,7 @@ static void show_ce_entry(const struct index_state *istate,
279292
}
280293
write_eolinfo(istate, ce, ce->name);
281294
write_name(ce->name);
282-
if (debug_mode) {
283-
const struct stat_data *sd = &ce->ce_stat_data;
284-
285-
printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
286-
printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
287-
printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
288-
printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
289-
printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
290-
}
295+
print_debug(ce);
291296
}
292297

293298
strbuf_release(&name);

0 commit comments

Comments
 (0)