add: do not accept pathspec magic 'attr'
[git/debian.git] / t / helper / test-dump-untracked-cache.c
blobf752532ffbcd130c3c3cb25ae20da41d4f74ae68
1 #include "cache.h"
2 #include "dir.h"
4 static int compare_untracked(const void *a_, const void *b_)
6 const char *const *a = a_;
7 const char *const *b = b_;
8 return strcmp(*a, *b);
11 static int compare_dir(const void *a_, const void *b_)
13 const struct untracked_cache_dir *const *a = a_;
14 const struct untracked_cache_dir *const *b = b_;
15 return strcmp((*a)->name, (*b)->name);
18 static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
20 int i, len;
21 QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked);
22 QSORT(ucd->dirs, ucd->dirs_nr, compare_dir);
23 len = base->len;
24 strbuf_addf(base, "%s/", ucd->name);
25 printf("%s %s", base->buf,
26 sha1_to_hex(ucd->exclude_sha1));
27 if (ucd->recurse)
28 fputs(" recurse", stdout);
29 if (ucd->check_only)
30 fputs(" check_only", stdout);
31 if (ucd->valid)
32 fputs(" valid", stdout);
33 printf("\n");
34 for (i = 0; i < ucd->untracked_nr; i++)
35 printf("%s\n", ucd->untracked[i]);
36 for (i = 0; i < ucd->dirs_nr; i++)
37 dump(ucd->dirs[i], base);
38 strbuf_setlen(base, len);
41 int cmd_main(int ac, const char **av)
43 struct untracked_cache *uc;
44 struct strbuf base = STRBUF_INIT;
46 /* Hack to avoid modifying the untracked cache when we read it */
47 ignore_untracked_cache_config = 1;
49 setup_git_directory();
50 if (read_cache() < 0)
51 die("unable to read index file");
52 uc = the_index.untracked;
53 if (!uc) {
54 printf("no untracked cache\n");
55 return 0;
57 printf("info/exclude %s\n", sha1_to_hex(uc->ss_info_exclude.sha1));
58 printf("core.excludesfile %s\n", sha1_to_hex(uc->ss_excludes_file.sha1));
59 printf("exclude_per_dir %s\n", uc->exclude_per_dir);
60 printf("flags %08x\n", uc->dir_flags);
61 if (uc->root)
62 dump(uc->root, &base);
63 return 0;