summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-06-12 22:14:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-13 18:40:52 (GMT)
commit5306ccf9e9ec7204eef409e90b57ddf23b8f5ca6 (patch)
tree3d084ec033d178f5aaab44e5c89cc6f7f148f449
parentf587c8dcdef17aea15aee45689e181b58b011706 (diff)
downloadgit-5306ccf9e9ec7204eef409e90b57ddf23b8f5ca6.zip
git-5306ccf9e9ec7204eef409e90b57ddf23b8f5ca6.tar.gz
git-5306ccf9e9ec7204eef409e90b57ddf23b8f5ca6.tar.bz2
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>
-rw-r--r--builtin/ls-files.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 55d6f54..c9307f9 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -93,6 +93,19 @@ static void write_name(const char *name)
strbuf_release(&full_name);
}
+static void print_debug(const struct cache_entry *ce)
+{
+ if (debug_mode) {
+ const struct stat_data *sd = &ce->ce_stat_data;
+
+ printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
+ printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
+ printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
+ printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
+ printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
+ }
+}
+
static void show_dir_entry(const char *tag, struct dir_entry *ent)
{
int len = max_prefix_len;
@@ -279,15 +292,7 @@ static void show_ce_entry(const struct index_state *istate,
}
write_eolinfo(istate, ce, ce->name);
write_name(ce->name);
- if (debug_mode) {
- const struct stat_data *sd = &ce->ce_stat_data;
-
- printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
- printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
- printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
- printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
- printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
- }
+ print_debug(ce);
}
strbuf_release(&name);