Skip to content

Commit

Permalink
ls-files: learn a debugging dump format
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Aug 2, 2010
1 parent 9d52f15 commit 8497421
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Documentation/git-ls-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ a space) at the start of each line:
lines, show only a partial prefix.
Non default number of digits can be specified with --abbrev=<n>.

--debug::
After each line that describes a file, add more data about its
cache entry. This is intended to show as much information as
possible for manual inspection; the exact format may change at
any time.

\--::
Do not interpret any more arguments as options.

Expand Down
9 changes: 9 additions & 0 deletions builtin/ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static int show_modified;
static int show_killed;
static int show_valid_bit;
static int line_terminator = '\n';
static int debug_mode;

static const char *prefix;
static int max_prefix_len;
Expand Down Expand Up @@ -162,6 +163,13 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
ce_stage(ce));
}
write_name(ce->name, ce_namelen(ce));
if (debug_mode) {
printf(" ctime: %d:%d\n", ce->ce_ctime.sec, ce->ce_ctime.nsec);
printf(" mtime: %d:%d\n", ce->ce_mtime.sec, ce->ce_mtime.nsec);
printf(" dev: %d\tino: %d\n", ce->ce_dev, ce->ce_ino);
printf(" uid: %d\tgid: %d\n", ce->ce_uid, ce->ce_gid);
printf(" size: %d\tflags: %x\n", ce->ce_size, ce->ce_flags);
}
}

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

Expand Down

0 comments on commit 8497421

Please sign in to comment.