]>
Commit | Line | Data |
---|---|---|
cd780f0b | 1 | #include "test-tool.h" |
a3ddcefd NTND |
2 | #include "cache.h" |
3 | #include "dir.h" | |
4 | ||
5 | static int compare_untracked(const void *a_, const void *b_) | |
6 | { | |
7 | const char *const *a = a_; | |
8 | const char *const *b = b_; | |
9 | return strcmp(*a, *b); | |
10 | } | |
11 | ||
12 | static int compare_dir(const void *a_, const void *b_) | |
13 | { | |
14 | const struct untracked_cache_dir *const *a = a_; | |
15 | const struct untracked_cache_dir *const *b = b_; | |
16 | return strcmp((*a)->name, (*b)->name); | |
17 | } | |
18 | ||
19 | static void dump(struct untracked_cache_dir *ucd, struct strbuf *base) | |
20 | { | |
21 | int i, len; | |
9ed0d8d6 RS |
22 | QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked); |
23 | QSORT(ucd->dirs, ucd->dirs_nr, compare_dir); | |
a3ddcefd NTND |
24 | len = base->len; |
25 | strbuf_addf(base, "%s/", ucd->name); | |
26 | printf("%s %s", base->buf, | |
70c369cd | 27 | oid_to_hex(&ucd->exclude_oid)); |
a3ddcefd NTND |
28 | if (ucd->recurse) |
29 | fputs(" recurse", stdout); | |
30 | if (ucd->check_only) | |
31 | fputs(" check_only", stdout); | |
32 | if (ucd->valid) | |
33 | fputs(" valid", stdout); | |
34 | printf("\n"); | |
35 | for (i = 0; i < ucd->untracked_nr; i++) | |
36 | printf("%s\n", ucd->untracked[i]); | |
37 | for (i = 0; i < ucd->dirs_nr; i++) | |
38 | dump(ucd->dirs[i], base); | |
39 | strbuf_setlen(base, len); | |
40 | } | |
41 | ||
cd780f0b | 42 | int cmd__dump_untracked_cache(int ac, const char **av) |
a3ddcefd NTND |
43 | { |
44 | struct untracked_cache *uc; | |
45 | struct strbuf base = STRBUF_INIT; | |
dae6c322 CC |
46 | |
47 | /* Hack to avoid modifying the untracked cache when we read it */ | |
48 | ignore_untracked_cache_config = 1; | |
49 | ||
1e8fef60 | 50 | setup_git_directory(); |
a3ddcefd NTND |
51 | if (read_cache() < 0) |
52 | die("unable to read index file"); | |
53 | uc = the_index.untracked; | |
54 | if (!uc) { | |
55 | printf("no untracked cache\n"); | |
56 | return 0; | |
57 | } | |
4b33e602 PO |
58 | printf("info/exclude %s\n", oid_to_hex(&uc->ss_info_exclude.oid)); |
59 | printf("core.excludesfile %s\n", oid_to_hex(&uc->ss_excludes_file.oid)); | |
a3ddcefd NTND |
60 | printf("exclude_per_dir %s\n", uc->exclude_per_dir); |
61 | printf("flags %08x\n", uc->dir_flags); | |
62 | if (uc->root) | |
63 | dump(uc->root, &base); | |
64 | return 0; | |
65 | } |