1 #define USE_THE_INDEX_VARIABLE
6 #include "read-cache-ll.h"
7 #include "repository.h"
10 static int compare_untracked(const void *a_
, const void *b_
)
12 const char *const *a
= a_
;
13 const char *const *b
= b_
;
14 return strcmp(*a
, *b
);
17 static int compare_dir(const void *a_
, const void *b_
)
19 const struct untracked_cache_dir
*const *a
= a_
;
20 const struct untracked_cache_dir
*const *b
= b_
;
21 return strcmp((*a
)->name
, (*b
)->name
);
24 static void dump(struct untracked_cache_dir
*ucd
, struct strbuf
*base
)
27 QSORT(ucd
->untracked
, ucd
->untracked_nr
, compare_untracked
);
28 QSORT(ucd
->dirs
, ucd
->dirs_nr
, compare_dir
);
30 strbuf_addf(base
, "%s/", ucd
->name
);
31 printf("%s %s", base
->buf
,
32 oid_to_hex(&ucd
->exclude_oid
));
34 fputs(" recurse", stdout
);
36 fputs(" check_only", stdout
);
38 fputs(" valid", stdout
);
40 for (i
= 0; i
< ucd
->untracked_nr
; i
++)
41 printf("%s\n", ucd
->untracked
[i
]);
42 for (i
= 0; i
< ucd
->dirs_nr
; i
++)
43 dump(ucd
->dirs
[i
], base
);
44 strbuf_setlen(base
, len
);
47 int cmd__dump_untracked_cache(int ac UNUSED
, const char **av UNUSED
)
49 struct untracked_cache
*uc
;
50 struct strbuf base
= STRBUF_INIT
;
52 /* Set core.untrackedCache=keep before setup_git_directory() */
53 xsetenv("GIT_CONFIG_COUNT", "1", 1);
54 xsetenv("GIT_CONFIG_KEY_0", "core.untrackedCache", 1);
55 xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
57 setup_git_directory();
58 if (repo_read_index(the_repository
) < 0)
59 die("unable to read index file");
60 uc
= the_index
.untracked
;
62 printf("no untracked cache\n");
65 printf("info/exclude %s\n", oid_to_hex(&uc
->ss_info_exclude
.oid
));
66 printf("core.excludesfile %s\n", oid_to_hex(&uc
->ss_excludes_file
.oid
));
67 printf("exclude_per_dir %s\n", uc
->exclude_per_dir
);
68 printf("flags %08x\n", uc
->dir_flags
);
70 dump(uc
->root
, &base
);