ls-files: factor out debug info into a function
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Jun 12, 2017 at 15:14 UTC
5306ccf9e9ec7204eef409e90b57ddf23b8f5ca6
1 file changed
+14
-9
builtin/ls-files.c
+14
-9
@@ -93,6 +93,19 @@ static void write_name(const char *name)
93
strbuf_release(&full_name);
94
}
95
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
+
109
static void show_dir_entry(const char *tag, struct dir_entry *ent)
110
{
111
int len = max_prefix_len;
@@ -279,15 +292,7 @@ static void show_ce_entry(const struct index_state *istate,
292
}
293
write_eolinfo(istate, ce, ce->name);
294
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);
296
}
297
298
strbuf_release(&name);