ls-files: use correct format string

struct stat_data and struct cache_time both use unsigned ints for all their members. However the format string for 'git ls-files --debug' currently uses %d for formatting these numbers. This means that we potentially print these values incorrectly if they are greater than INT_MAX. This has been the case since the --debug option was introduced in 'git ls-files' in 8497421715 ("ls-files: learn a debugging dump format", 2010-07-31). Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Gummerer committed Apr 7, 2019 at 19:47 UTC 7cb7283adb817dff660d237fcba9cce9db594034
1 file changed +5 -5
builtin/ls-files.c
+5 -5
@@ -112,11 +112,11 @@ static void print_debug(const struct cache_entry *ce)
112 if (debug_mode) {
113 const struct stat_data *sd = &ce->ce_stat_data;
114
115 - printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
116 - printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
117 - printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
118 - printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
119 - printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
115 + printf(" ctime: %u:%u\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
116 + printf(" mtime: %u:%u\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
117 + printf(" dev: %u\tino: %u\n", sd->sd_dev, sd->sd_ino);
118 + printf(" uid: %u\tgid: %u\n", sd->sd_uid, sd->sd_gid);
119 + printf(" size: %u\tflags: %x\n", sd->sd_size, ce->ce_flags);
120 }
121 }
122