2019-01-24 08:29:12 +00:00
|
|
|
#define USE_THE_INDEX_COMPATIBILITY_MACROS
|
2018-09-09 17:36:27 +00:00
|
|
|
#include "test-tool.h"
|
2015-03-08 10:12:44 +00:00
|
|
|
#include "cache.h"
|
|
|
|
#include "dir.h"
|
|
|
|
|
|
|
|
static int compare_untracked(const void *a_, const void *b_)
|
|
|
|
{
|
|
|
|
const char *const *a = a_;
|
|
|
|
const char *const *b = b_;
|
|
|
|
return strcmp(*a, *b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int compare_dir(const void *a_, const void *b_)
|
|
|
|
{
|
|
|
|
const struct untracked_cache_dir *const *a = a_;
|
|
|
|
const struct untracked_cache_dir *const *b = b_;
|
|
|
|
return strcmp((*a)->name, (*b)->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
|
|
|
|
{
|
|
|
|
int i, len;
|
2016-09-29 15:27:31 +00:00
|
|
|
QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked);
|
|
|
|
QSORT(ucd->dirs, ucd->dirs_nr, compare_dir);
|
2015-03-08 10:12:44 +00:00
|
|
|
len = base->len;
|
|
|
|
strbuf_addf(base, "%s/", ucd->name);
|
|
|
|
printf("%s %s", base->buf,
|
2018-05-02 00:25:48 +00:00
|
|
|
oid_to_hex(&ucd->exclude_oid));
|
2015-03-08 10:12:44 +00:00
|
|
|
if (ucd->recurse)
|
|
|
|
fputs(" recurse", stdout);
|
|
|
|
if (ucd->check_only)
|
|
|
|
fputs(" check_only", stdout);
|
|
|
|
if (ucd->valid)
|
|
|
|
fputs(" valid", stdout);
|
|
|
|
printf("\n");
|
|
|
|
for (i = 0; i < ucd->untracked_nr; i++)
|
|
|
|
printf("%s\n", ucd->untracked[i]);
|
|
|
|
for (i = 0; i < ucd->dirs_nr; i++)
|
|
|
|
dump(ucd->dirs[i], base);
|
|
|
|
strbuf_setlen(base, len);
|
|
|
|
}
|
|
|
|
|
2018-09-09 17:36:27 +00:00
|
|
|
int cmd__dump_untracked_cache(int ac, const char **av)
|
2015-03-08 10:12:44 +00:00
|
|
|
{
|
|
|
|
struct untracked_cache *uc;
|
|
|
|
struct strbuf base = STRBUF_INIT;
|
2016-01-27 06:58:06 +00:00
|
|
|
|
2021-09-21 13:13:00 +00:00
|
|
|
/* Set core.untrackedCache=keep before setup_git_directory() */
|
|
|
|
xsetenv("GIT_CONFIG_COUNT", "1", 1);
|
|
|
|
xsetenv("GIT_CONFIG_KEY_0", "core.untrackedCache", 1);
|
|
|
|
xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
|
2016-01-27 06:58:06 +00:00
|
|
|
|
2015-03-08 10:12:46 +00:00
|
|
|
setup_git_directory();
|
2015-03-08 10:12:44 +00:00
|
|
|
if (read_cache() < 0)
|
|
|
|
die("unable to read index file");
|
|
|
|
uc = the_index.untracked;
|
|
|
|
if (!uc) {
|
|
|
|
printf("no untracked cache\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-01-28 00:13:12 +00:00
|
|
|
printf("info/exclude %s\n", oid_to_hex(&uc->ss_info_exclude.oid));
|
|
|
|
printf("core.excludesfile %s\n", oid_to_hex(&uc->ss_excludes_file.oid));
|
2015-03-08 10:12:44 +00:00
|
|
|
printf("exclude_per_dir %s\n", uc->exclude_per_dir);
|
|
|
|
printf("flags %08x\n", uc->dir_flags);
|
|
|
|
if (uc->root)
|
|
|
|
dump(uc->root, &base);
|
|
|
|
return 0;
|
|
|
|
}
|