Skip to content

Commit 8497421

Browse files
trastgitster
authored andcommitted
ls-files: learn a debugging dump format
Teach git-ls-files a new option --debug that just tacks all available data from the cache onto each file's line. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9d52f15 commit 8497421

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Documentation/git-ls-files.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ a space) at the start of each line:
140140
lines, show only a partial prefix.
141141
Non default number of digits can be specified with --abbrev=<n>.
142142

143+
--debug::
144+
After each line that describes a file, add more data about its
145+
cache entry. This is intended to show as much information as
146+
possible for manual inspection; the exact format may change at
147+
any time.
148+
143149
\--::
144150
Do not interpret any more arguments as options.
145151

builtin/ls-files.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static int show_modified;
2525
static int show_killed;
2626
static int show_valid_bit;
2727
static int line_terminator = '\n';
28+
static int debug_mode;
2829

2930
static const char *prefix;
3031
static int max_prefix_len;
@@ -162,6 +163,13 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
162163
ce_stage(ce));
163164
}
164165
write_name(ce->name, ce_namelen(ce));
166+
if (debug_mode) {
167+
printf(" ctime: %d:%d\n", ce->ce_ctime.sec, ce->ce_ctime.nsec);
168+
printf(" mtime: %d:%d\n", ce->ce_mtime.sec, ce->ce_mtime.nsec);
169+
printf(" dev: %d\tino: %d\n", ce->ce_dev, ce->ce_ino);
170+
printf(" uid: %d\tgid: %d\n", ce->ce_uid, ce->ce_gid);
171+
printf(" size: %d\tflags: %x\n", ce->ce_size, ce->ce_flags);
172+
}
165173
}
166174

167175
static int show_one_ru(struct string_list_item *item, void *cbdata)
@@ -519,6 +527,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
519527
OPT_STRING(0, "with-tree", &with_tree, "tree-ish",
520528
"pretend that paths removed since <tree-ish> are still present"),
521529
OPT__ABBREV(&abbrev),
530+
OPT_BOOLEAN(0, "debug", &debug_mode, "show debugging data"),
522531
OPT_END()
523532
};
524533

0 commit comments

Comments
 (0)