mirror of
https://github.com/git/git
synced 2024-09-18 07:51:35 +00:00
ccd12a3d6c
More header clean-up. * en/header-split-cache-h-part-2: (22 commits) reftable: ensure git-compat-util.h is the first (indirect) include diff.h: reduce unnecessary includes object-store.h: reduce unnecessary includes commit.h: reduce unnecessary includes fsmonitor: reduce includes of cache.h cache.h: remove unnecessary headers treewide: remove cache.h inclusion due to previous changes cache,tree: move basic name compare functions from read-cache to tree cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c hash-ll.h: split out of hash.h to remove dependency on repository.h tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h dir.h: move DTYPE defines from cache.h versioncmp.h: move declarations for versioncmp.c functions from cache.h ws.h: move declarations for ws.c functions from cache.h match-trees.h: move declarations for match-trees.c functions from cache.h pkt-line.h: move declarations for pkt-line.c functions from cache.h base85.h: move declarations for base85.c functions from cache.h copy.h: move declarations for copy.c functions from cache.h server-info.h: move declarations for server-info.c functions from cache.h packfile.h: move pack_window and pack_entry from cache.h ...
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
#define USE_THE_INDEX_VARIABLE
|
|
#include "test-tool.h"
|
|
#include "cache.h"
|
|
#include "dir.h"
|
|
#include "hex.h"
|
|
#include "repository.h"
|
|
#include "setup.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;
|
|
QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked);
|
|
QSORT(ucd->dirs, ucd->dirs_nr, compare_dir);
|
|
len = base->len;
|
|
strbuf_addf(base, "%s/", ucd->name);
|
|
printf("%s %s", base->buf,
|
|
oid_to_hex(&ucd->exclude_oid));
|
|
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);
|
|
}
|
|
|
|
int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)
|
|
{
|
|
struct untracked_cache *uc;
|
|
struct strbuf base = STRBUF_INIT;
|
|
|
|
/* 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);
|
|
|
|
setup_git_directory();
|
|
if (repo_read_index(the_repository) < 0)
|
|
die("unable to read index file");
|
|
uc = the_index.untracked;
|
|
if (!uc) {
|
|
printf("no untracked cache\n");
|
|
return 0;
|
|
}
|
|
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));
|
|
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;
|
|
}
|