ls-files: use correct format string
authorThomas Gummerer <t.gummerer@gmail.com>
Sun, 7 Apr 2019 18:47:51 +0000 (19:47 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Apr 2019 08:01:52 +0000 (17:01 +0900)
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>
builtin/ls-files.c
index 29a8762d46eb7aa9a9b456e2564062fdbdb48a06..463105ccb555efdb28efc6c68919b8dd14b5eb31 100644 (file)
@@ -112,11 +112,11 @@ 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);
+               printf("  ctime: %u:%u\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
+               printf("  mtime: %u:%u\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
+               printf("  dev: %u\tino: %u\n", sd->sd_dev, sd->sd_ino);
+               printf("  uid: %u\tgid: %u\n", sd->sd_uid, sd->sd_gid);
+               printf("  size: %u\tflags: %x\n", sd->sd_size, ce->ce_flags);
        }
 }