1 #define USE_THE_INDEX_VARIABLE
8 static int compare_untracked(const void *a_
, const void *b_
)
10 const char *const *a
= a_
;
11 const char *const *b
= b_
;
12 return strcmp(*a
, *b
);
15 static int compare_dir(const void *a_
, const void *b_
)
17 const struct untracked_cache_dir
*const *a
= a_
;
18 const struct untracked_cache_dir
*const *b
= b_
;
19 return strcmp((*a
)->name
, (*b
)->name
);
22 static void dump(struct untracked_cache_dir
*ucd
, struct strbuf
*base
)
25 QSORT(ucd
->untracked
, ucd
->untracked_nr
, compare_untracked
);
26 QSORT(ucd
->dirs
, ucd
->dirs_nr
, compare_dir
);
28 strbuf_addf(base
, "%s/", ucd
->name
);
29 printf("%s %s", base
->buf
,
30 oid_to_hex(&ucd
->exclude_oid
));
32 fputs(" recurse", stdout
);
34 fputs(" check_only", stdout
);
36 fputs(" valid", stdout
);
38 for (i
= 0; i
< ucd
->untracked_nr
; i
++)
39 printf("%s\n", ucd
->untracked
[i
]);
40 for (i
= 0; i
< ucd
->dirs_nr
; i
++)
41 dump(ucd
->dirs
[i
], base
);
42 strbuf_setlen(base
, len
);
45 int cmd__dump_untracked_cache(int ac
, const char **av
)
47 struct untracked_cache
*uc
;
48 struct strbuf base
= STRBUF_INIT
;
50 /* Set core.untrackedCache=keep before setup_git_directory() */
51 xsetenv("GIT_CONFIG_COUNT", "1", 1);
52 xsetenv("GIT_CONFIG_KEY_0", "core.untrackedCache", 1);
53 xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
55 setup_git_directory();
56 if (repo_read_index(the_repository
) < 0)
57 die("unable to read index file");
58 uc
= the_index
.untracked
;
60 printf("no untracked cache\n");
63 printf("info/exclude %s\n", oid_to_hex(&uc
->ss_info_exclude
.oid
));
64 printf("core.excludesfile %s\n", oid_to_hex(&uc
->ss_excludes_file
.oid
));
65 printf("exclude_per_dir %s\n", uc
->exclude_per_dir
);
66 printf("flags %08x\n", uc
->dir_flags
);
68 dump(uc
->root
, &base
);